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 trial

Java

The String variable in Java

Why do String declarations need a capital S for 'String' while 'int' , 'char', 'boolean' types are all ok with lower case?

This is 90% just a moan and 10% out of interest.

3 Answers

int, float, char etc are primitive types, whereas String is a java class. Classes start with capital letters

for a list of primitive types, consult the Java documentation on primitives

for a rundown of primitive types vs classes see this article

Thank you again Stone now more interested than moaning!!

It says that int,bool, char are primitive variables while String is class variable. primitive variables are simple and have a max size so they can be easily stored/handled. Whereas Class variables have the possibility of being complex and massive. This potentially effects memory usage where things are stored etc so I should think of String as just a kind of special variable type and put a big S there without moaning.

String as just a kind of special variable type

pretty much. variables of classes are known as objects (the object part of object oriented programming), which opens up a different can of worms. but for now yes you can just know that String is not a primitive type, it is a class and is inherently different. Since its a class its type needs to start with a capital letter (in this case String)