Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   I'm Sure This Is An Easy Question... (http://www.programmingforums.org/showthread.php?t=1341)

JawaKing00 Nov 29th, 2004 6:26 PM

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.

Mjordan2nd Nov 29th, 2004 6:49 PM

:

char c = str.charAt(0);

JawaKing00 Nov 29th, 2004 8:34 PM

Thank you.

I knew it had to be something simple, I just wasn't finding it

eccles Nov 30th, 2004 7:08 PM

isn't there also a way to read from System.in char by char?

KwizatzHaderach Nov 30th, 2004 10:40 PM

:

char[] inputChars=input.toCharArray();
char inp=inputChars[0];


Mjordan2nd Nov 30th, 2004 11:38 PM

Fixed code tags in post preceding mine.


All times are GMT -5. The time now is 2:29 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC