Summary of Class Presentation for June 10, 1999 Java has eight primitive data types, namely: Integers: Byte -128 to 127 Short 16 bits Int 32 bits Long 64 bits Floats: Float 32 bits Double 64 bits Others: Boolean true, false Char 16 bits Unicode Among the integers, a shorter type variable or constant may be assigned to a longer type variable and conversion will be done automatically. Assignment of a longer type variable or constant may be done to a shorter type variable only by using an explicit cast. Unlike C or C++, there are no unsigned integers. The lengths and ranges of the types are defined by the language and cannot vary from implementation to implementation. Among the floats, conversion from floats to doubles is automatic. Using a double for assignment to a float is possible, but only with an explicit cast. Since the cast does no actual conversion, the result usually is not what you expect. Only the truncated bits are used. Other conversions among these eight primitive types are not allowed. Everything else in Java software is an object or a class. When parameters are passed in Java, they are always passed by value. This means a copy of the value is made and that is passed. However, every object is actually a reference to a piece of memory containing the instance variable values and a table providing access to the member methods plus a reference to the containing class ( the one the object's class inherits from). Thus when an object is passed, the reference is copied and used. This means the original object's data can be changed in the called method by changing the parameter's data fields. The same gotcha occurs on assignments. If there are two objects, a and b, an assignment of a to b results in a and b having the same reference value and hence each being an alias for the same data fields. This gotcha also occurs on relational tests. For example if a and b are objects, a == b is only true if a and b contain the same reference value. There is a method that compares the data values referenced by the two objects and we will describe this method ( equal) in a later class. We also looked at the operators available in Java. Nearly all are the same as those in C++.