Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

isLetter Method not working

229 views
Skip to first unread message

Chris

unread,
Jun 13, 2000, 3:00:00 AM6/13/00
to
Hello,

Can someone tell me why the following code doesn't work?

The compiler gives me the following error:
"test.java"":Error #:300: method isLetter(char) not found...

Many other simple programs like this work so I know the IDE is working
(JBuilder 3.5).

import java.lang.Character; // java.lang automatically included, but I need
it to work!
public class test {
public static void main(String args[]) {
char x;
x = 'x';
if (isLetter(x)) // not acceptable?
System.out.println("Is letter");
}
}

Any help appreciated,
Chris

deevo

unread,
Jun 13, 2000, 3:00:00 AM6/13/00
to
In article <zEi15.1429$fE2....@news1.rdc2.pa.home.com>,

isLetter() is a static method in class Character. Use :-

if (Character.isLetter (cMyChar)) ...

instead.

steve


Sent via Deja.com http://www.deja.com/
Before you buy.

Jim White

unread,
Jun 13, 2000, 3:00:00 AM6/13/00
to
Chris wrote in message ...

>The compiler gives me the following error:
>"test.java"":Error #:300: method isLetter(char) not found...
>...

Don't do it that way, do it this way:

public class test {
public static void main(String args[]) {
char x;
x = 'x';

if (Character.isLetter(x)) // not acceptable?
System.out.println("Is letter");
}
}

The import is *not* needed, because as you say, java.lang.* is imported
by default.

The error was telling you that no method named 'isLetter' existed in
your class 'test'.

jim
------------------------------------------------------------
James P. White Netscape DevEdge Champion for IFC
IFC Exchange - Insanely great Java - http://www.ifcx.org

Heinrich Meyer

unread,
Jun 13, 2000, 3:00:00 AM6/13/00
to
Chris schrieb:

> Hello,
>
> Can someone tell me why the following code doesn't work?
>

> The compiler gives me the following error:
> "test.java"":Error #:300: method isLetter(char) not found...
>

> Many other simple programs like this work so I know the IDE is working
> (JBuilder 3.5).
>
> import java.lang.Character; // java.lang automatically included, but I need
> it to work!

> public class test {
> public static void main(String args[]) {
> char x;
> x = 'x';

> if (isLetter(x)) // not acceptable?
> System.out.println("Is letter");
> }
> }
>
> Any help appreciated,
> Chris

"import java.lang.Character" doesn't mean, that you can
reference the fields of `Character´ without the leading
class reference. It only implies that you can
write`"Character" instead of "java.lang.Character". But
in the case of the "java.lang" package, this doesn't
change anything because there is an implicit "import
java.lang.*" in every source file

Bye

Chris

unread,
Jun 13, 2000, 3:00:00 AM6/13/00
to
Gosh Golly.. Thanks so much!
Chris
"Heinrich Meyer" <Ferienh...@t-online.de> wrote in message
news:39461A02...@t-online.de...
0 new messages