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!
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 trial

Nils Garland
18,416 PointsJava variable case
Why is it that when I declare a variable of type String I type it out with a capital S. But when I do Int I have to do it with lower case? Is there any specific reason?
String name = console.readLine("Enter your name: ");
int age = Integer.parseInt(ageAsString);
1 Answer

Jennifer Nordell
Treehouse TeacherHi there! Essentially, it's because the int
is a primitive data type. Java provides support for strings through the use of the java.lang.String
class. And because this is all case sensitive you have to use the capitalization specified. Here's some documentation on the primitive data types including information about the String class.
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
Hope this helps!
Simon Coates
28,693 PointsSimon Coates
28,693 Pointsunsure if it's a convention or a rule, but primitive types are lower case, while object types are Upper case. At the very least, it's a visual clue. I assume you understand pass by value/reference, so can appreciate why being able to see at a glance the object/primitive distinction is a useful when writing code.