CPSC 233 Lecture Notes - Lecture 5: String Literal, Boeing 737 Max, Memory Management
Document Summary
Are like variables, except their value cannot be changed once initialized. Declared using the keyword final (eg. ) final int max = 10; final double pi = 3. 14; Use string stringbuffer class to store strings that may change. The complier creates a string object for each string literal in source code. Essentially they are pointers to objects created on heap memory. Vector myvector; (vector class) (object reference) myvector = new vector(); Created object (on the heap memory) is assigned to (creates a vector object on the heap memory) myvector. Variables are set to zero unless explicitly initialized byte, short, int and long 0 float and double 0. 0 char. Two basic types are: variable declarations executable statements. Are terminated with ; (eg. ) double x = 3. 5; import java. awt. graphics; value = 3 * i; The expression is evaluated and the result stored in the variable (eg. ) x = 3. 3; Expressions are a combinations of operators and operands.