aspose file tools
The moose likes Beginning Java and the fly likes Converting string into a char Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Converting string into a char" Watch "Converting string into a char" New topic
Author

Converting string into a char

Rich Barry
Greenhorn

Joined: Jan 28, 2002
Posts: 19
Hi...
I want to change a string into a char... so I am going to use the charAt function... and I am not sure what I am doing...
so I include the method where I am trying to convert it... the *** indicates where I am trying to use the charAt function...
Thx
Rich
private void deposit(){
String accounttype;
double depositamt;
System.out.println("Account Deposit:");
System.out.print("\n\tEnter the amount you wish to deposit: ");
depositamt = new Double(readit()).doubleValue();
System.out.println("\n\tEnter the account you wish to use.. C (chequing) S (savings)");
accounttype = readit();
***** accounttype charAt(0); *****
System.out.println(accounttype + depositamt);
Account acct = new Account();
acct.deposit(depositamt, accounttype);
}
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
char acctTypeChar = accountType.charAt(0);
You are going to need to deal with Cap input, and what if they enter a space before they enter the character, etc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Converting string into a char
 
Similar Threads
getting a variable from another method??
Read data?
Constructor issues with creating a new checking account object.
comparing a values with user input
Different character sets on Unix/Windows? Whats happening?