![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Sep 2004
Posts: 29
Rep Power: 0
![]() |
Ok,
For my Java class I need to implement the Farmer/Wolf/Goat/Cabbage puzzle. For the input to the program I am to use command line arguments that will be just the letters E or W indicating which side of the river each thing is on and which side they should be on when finished. What I want to do is take the String arguments passed and change them into char variables so I can easily compare them and such. I can't seem to figure out how to change a string of one letter into a char though. Can anyone give me some form of advice? Thank you. |
|
|
|
|
|
#2 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
char c = str.charAt(0);
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Sep 2004
Posts: 29
Rep Power: 0
![]() |
Thank you.
I knew it had to be something simple, I just wasn't finding it |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Nov 2004
Posts: 16
Rep Power: 0
![]() |
isn't there also a way to read from System.in char by char?
|
|
|
|
|
|
#5 |
|
Newbie
Join Date: Nov 2004
Posts: 8
Rep Power: 0
![]() |
char[] inputChars=input.toCharArray(); char inp=inputChars[0]; |
|
|
|
|
|
#6 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
Fixed code tags in post preceding mine.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|