Game Development Reference
In-Depth Information
create the Java programming logic that will eventually define your game app's game
play.
Java Data Types: Defining Data Type in
Applications
Because you have already learned about variables and constants encountered in a few
of Java's data types, let's explore these next, as it is not too advanced for your current
progression from easy to more difficult topics!
There are two primary data type classifications in Java: primitive data types ,
which are the ones that you are the most familiar with if you have used a different pro-
gramming language, and reference (object) data types , which you will know about if
you have used another OOP language, such as Lisp, Python, Objective-C, C++, or C#
(C Sharp).
Primitive Data Types: Characters, Numbers, and
Boolean (Flags)
There are eight primitive data types in the Java programming language, as shown in
Table 3-1 . You will be using these as you work your way through the topic to create
your InvinciBagel game, so I am not going to go into detail regarding each one of them
now, except to say that Java boolean data variables are used for flags or switches (on/
off), char is used for Unicode characters or to create String objects (an array of char),
and the rest are used to hold numeric values of different sizes and resolutions. Integer
values hold whole numbers, whereas a floating point value holds fractional (decimal
point value) numbers. It is important to use the right numeric data type for a variable's
scope, or range, of use, because, as you can see in Binary Size column in Table 3-1 ,
large numeric data types can use up to eight times more memory than the smaller ones.
Table 3-1 . Java Primitive Data Types, Along with Their Default Values, Size in Memory,
Definition, and Numeric Range
 
 
Search WWH ::




Custom Search