how can i solve this error.??

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

:)

Recommended Answers

All 5 Replies

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.

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?

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).

ok thanx alot:)

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.