Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialUnsubscribed User
8,838 PointsJava Basics - Error method readline in class Console cannot be applied to give types;
So I am doing Java Basics and I am on the Parsing Integers video. I copied exactly what the video said.
Here is my code:
String ageAsString = console.readline("How old are you? ");
int age = Integer.parseInt(ageAsString);
if (age < 13) {
//Exit code
console.printf("Sorry you must be at least 13 to use this program.\n");
System.exit(0);
}
This is the error it gave me:
TreeStory.java:13: error: method readline in class Console cannot be applied to given types;
String ageAsString = console.readline("How old are you? ");
^
required: boolean
found: String
reason: argument mismatch; String cannot be converted to boolean
1 error
Thanks if you can help!
Max ;)
2 Answers
Michael De Marre
14,198 PointsreadLine() is case sensitive. You have it written as readline(). Try capitalizing the L. There is actually another method titled readline() for a different type of class (Console for readLine, BufferedReader for readline).
Gunjeet Hattar
14,483 PointsHi Max,
Change readline to read*L*ine .. capitalise the L and check if it works
Unsubscribed User
8,838 PointsUnsubscribed User
8,838 PointsThank you Micheal! ;)