Game Development Reference
In-Depth Information
Data Modifiers
Data modifiers allow the programmer to control how variables are accessed and stored.
They include the following:
private: Variables that are private are only accessible from within the class they
are declared in. The following declares m_ProjectionMatrix to be private and
only accessible from within its own class:
private float [] m_ProjectionMatrix = new float [16];
public: Variables that are public can be accessed from any class. The following
variable is public:
public float [] m_ProjectionMatrix = new float [16];
static: Variables that are declared static have only one copy associated with
the class they are declared in. The following static array is declared static and
resides in the Cube class. This array defines the graphics data for a 3D cube.
This 3D cube is the same for all instances of the Cube class, so it makes sense
to make the CubeData array static.
static float CubeData[] =
{
// x, y, z, u, v nx, ny, nz
-0.5f, 0.5f, 0.5f, 0.0f, 0.0f, -1, 1, 1, // front top left
-0.5f, -0.5f, 0.5f, 0.0f, 1.0f, -1, -1, 1, // front bottom left
0.5f, -0.5f, 0.5f, 1.0f, 1.0f, 1, -1, 1, // front bottom right
0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1, 1, 1, // front top right
-0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1, 1, -1, // back top left
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f, -1, -1, -1, // back bottom left
0.5f, -0.5f, -0.5f, 1.0f, 1.0f, 1, -1, -1, // back bottom right
0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 1, 1, -1 // back top right
};
final: The final modifier indicates that the variable will not change. For example,
the following declares the variable TAG is of type String and is private, static,
and cannot be changed.
private static final String TAG = "MyActivity";
Java Operators
In this section, we cover arithmetic, unary, conditional, bitwise, and bit shift operators.
 
Search WWH ::




Custom Search