Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cannot find method readChar() 1

Status
Not open for further replies.

Ito2233

MIS
Sep 2, 2003
77
US
Newbie here. I have the following simple program. The readChar() method, which reads in character values and returns the integer equivalent, is located in the tio package being imported. Yet the compiler keeps telling me:

cannot resolve symbol
symbol: method readChar ()
location: class charToInt
int_equiv = readChar();

Here is my program:
____________________________________
import tio.*;

class charToInt {
public static void main (String[] args) {
int int_equiv;
System.out.println("Type in characters followed by
ENTER. The computer will print the integer
equivalents. To quit, hit Ctrl-Z.");
int_equiv = readChar();
while (int_equiv != -1) {
System.out.println((char) int_equiv + "is " +
int_equiv + " in integer notation.");
int_equiv = readChar();
}
}
}

THANKS!!!!!!!!
 
Well - the method readChar () isn't only defined in your package tio, but in mio, rio, hio and cio.
So you have to specify the class, which defines this method.
If it is Foo, you write
Code:
int_equiv = Foo.readChar ();
if the method is static.
If not, you need a Foo-Object:

Code:
Foo foo = new Foo ();
int_equiv = foo.readChar ();

(ctor of Foo is only guessed by me)
 
Thanks for the tip. I have looked over the classes in the tio package and have managed to make the program work!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top