0

how can i solve this error.??

incompatible types
found : java.lang.String
required: int
num=userIn.readLine();

:)

2
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by JamesCherrill
0

Chesk the JavaDoc.. What type does readLine() return? What type is your variable num? That's why you get the error message.

Which method in the same class as readLine() returns an integer? That's the one you need.

0

Chesk the JavaDoc.. What type does readLine() return? What type is your variable num? That's why you get the error message.

Which method in the same class as readLine() returns an integer? That's the one you need.

aha thnx:) the num is int.
but how can i read the int from the keyboard?

0

Read the JavaDoc - very near to readLine you'll find a method that returns an int.
(Researching the JavaDoc is an essential skill to practice).

0

OOps - think I may you an apology. You didn't show the code where "user" was declared, and I probably guessed wrong, and thus gave bad advice.
If, as I now suspect, "user" is one of the Reader classes then it won't have a method to read ints directly. If that's the case, look at Integer.parseInt(String s).

Sorry
J

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.