
Signature
Lothar Kimmeringer E-Mail: spamfang@kimmeringer.de
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)
Always remember: The answer is forty-two, there can only be wrong
questions!
> > Error: incompatible types
> > found : java.lang.String
[quoted text clipped - 7 lines]
> String is not char. So you have to get the first char of the
> String with charAt(0).
But when I run the main class I need to type the char I want to search the
string for. Something like this in the console:
java TestSearch k punk
where "k" is the char I am seaching the string "punk" for.
JS
JS - 08 Dec 2004 18:49 GMT
> > > Error: incompatible types
> > > found : java.lang.String
[quoted text clipped - 7 lines]
> > String is not char. So you have to get the first char of the
> > String with charAt(0).
Now I get it:
String p = args[0];
char r = p.charAt(0);
and now I can use r as my first argument!
Sorry for not thinking before asking
JS
Nicholas Parnell - 08 Dec 2004 21:13 GMT
you would assign argument to a string first and then cast it to a char.
You might want to do a test case first to make sure the length of the string
is 1.
> > > Error: incompatible types
> > > found : java.lang.String
[quoted text clipped - 16 lines]
>
> JS
Chris Smith - 09 Dec 2004 19:26 GMT
> you would assign argument to a string first and then cast it to a char.
> You might want to do a test case first to make sure the length of the string
> is 1.
Well, you don't need a variable for something so simple. Works just
fine to say:
char c = args[0].charAt(0);
(Please don't top-post.)

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation