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 trialTomás Borges
4,394 PointsDoes the readLine method only return String data?
So, I typed 333 as my input when the readLine method was called and it worked, why? (Even though the returned value was stored in a String variable)
1 Answer
Tomás Borges
4,394 PointsIt helped, thanks!
Patrick Bluth
13,285 PointsPatrick Bluth
13,285 PointsYes, the readLine() method only returns a String value. So typing 333 as the input on the readLine is equivalent to setting a variable to "333" in your Java code. If you needed to get the integer datatype from the readLine method, you would first need to return a String value and then convert it to an integer using parseInt(), like so:
Hope that helps