A complete program instruction is called a statement. Each statement ends with a semicolon (;).
All objects, constants, and variables must have a specific type.
Most of the intrinsic types are used for working with numeric
values. You will commonly use int
for whole numbers and double
or
float
for fractional
values.
The char
type is used for
holding a single character.
The bool
type can only hold
the value true or false.
A variable is an instance of an intrinsic type. You initialize a variable by creating it with an assigned value.
A constant is similar to a variable, but the value cannot be changed while the program is running.
An enumeration is a value type that consists of a set of named constants.
You can cast a value from one type to another as long as either the compiler knows how to turn the original type into the cast-to type, or you provide a method in your class definition that tells the compiler how to make the cast.
If no information can be lost, you may cast from one type to another implicitly.
If information may be lost (such as when casting from a long to an integer), you must cast explicitly.
A string object holds a series of characters (such as a word or sentence).
String objects are immutable; when you appear to be changing a string’s value, you are actually creating a new string.
Expressions are statements that evaluate to a value.
Extra whitespace (spaces, tabs, and newline characters) that is not within a string, is ignored by the compiler.