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 Java Arrays Creation Declaring Arrays

what does "primitive" mean?

examples?

1 Answer

The primitive data types in Java are byte, short, int, long, float, double, boolean, and char. They are built into the language, and have a value, but no methods.

'a' with single quotes is a char, which is a primitive type. "a" with double quotes is a String, which is not a primitive type.

Primitive data types are not objects. You can't call methods directly on them: 'a'.toString() will give the error char cannot be dereferenced. "a".toString() returns "a".

Two primitive types with the same value will be equal with the == operator: 'a' == 'a' is true, but new String("a") == new String("a") is false, and new String("a").equals(new String("a")) is true.