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 trialAkashdeep Matharu
1,719 PointsWhy age entering by user is in string?
Why we have to take String as variable for input a number? Why not take a int for readLine?
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! Cevin Thomas is 100% correct. Anything coming in from the console/command line will be a String. It's interesting to note that this is not exclusive to Java. This applies to just about every programming language I've ever come across. In fact, I can't remember any programming language where the input from the user comes in as anything other than a String. So when you get in the input, if it needs to be an integer, there will also need to be some sort of parsing done. This is true for at least Java, ANSI C/C++/C#, and I believe it also to be true for Python and Ruby.
Hope this helps!
Cevin Thomas
3,577 PointsCevin Thomas
3,577 PointsI believe (fairly new to this), that when you use the method readLine, anything that comes through the input from another user, is considered a String. I am not 100% sure.