Java programs manipulate two fundamentally different kinds of values: primitive values and object values.
All primitive values belong to one of eight primitive types: int, float, boolean, char, byte, short, long, and double. Four of these types are different sizes of bounded integers: byte ranging from -128 to 127; short ranging from -32,768 to 32,767; int ranging from -2147483648 to 2147483647; and long ranging from -9223372036854775808 to 9223372036854775807. The boolean type has two values true and false. The char type supports the Unicode character set which includes all conventional ASCII characters plus almost any foreign character imaginable. The char type is rarely used in Java programs because a flexible String object type is built-in to the language. The remaining two types float and double are used for approximate computations involving real numbers.
Object values are created by instantiating classes, which may either be built-in or program-defined. Classes are organized in a hierarchy. Every class C except the special built-in class Object has a unique parent in the hierarchy called the superclass of C. A descendant in the class hierarchy is called a subclass. The Object class is the top class in the hierarchy and serves as the default superclass for program-defined classes.
Every Java class C has an associated type C consisting of all instances of class C and all of its subclasses. Hence, the type Object contains all object values. The built-in class String has the class Object as its superclass. Since the class String has no subclasses, the only values of type String are instances of the class String.
Object values are actually references to objects. For this reason, two different fields can be bound to exactly the same object.
In Java, every field and method has a declared type given as part of its definition. For a method, the declared type includes the type of the result and the types of the parameters. In the Hello class above, the main method has result type void, which is empty. In Java, there are no values of type void. A method with void return type does not return a value.
Java determines the type of every program expression using a simple set of rules and confirms that