| 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.
|
 |
 |
|
|
subject: Converting string into a char
|
|
|