01/03/2025
Java Basic Syntax guide
Prepared by: Dr. Ronnel Agulto
Hello, World.
1
01/03/2025
Editing, compiling, and executing.
Built in data types
• primitive
• reference
2
01/03/2025
Primitive data types
1.byte
2.short
3.int
4.long
5.float
6.double
7.char
8.boolean
Built-in data types.
3
01/03/2025
Declaration and assignment
statements.
byte
• Size: 8-bit
• Range: -128 to 127
• Used for saving memory in large arrays and when dealing with raw
data from files or networks.
4
01/03/2025
short
• Size: 16-bit
• Range: -32,768 to 32,767
• useful for applications requiring a number range wider than ‘byte’
Integer
• Size: 32-bit
• Range: -2^31 to 2^31-1
• Commonly used as the
default data type for
integer values.
5
01/03/2025
long
• Size: 64-bit
• Range: -2^63 to 2^63-1
• Used when a wider range than ‘int’ is needed, append ‘L’ to indicate a
long literal.
Floating-point
numbers.
• Size: 32-bit
• Range: Approximately
±3.40282347E+38F (6-
7 significant decimal
digits)
• Used for precise
values that require
fractional parts,
append’f’ to indicate a
float literal.
6
01/03/2025
double
• Size: 64-bit
• Range: Approximately ±1.79769313486231570E+308 (15 significant
decimal digits)
• Default data type for decimal values, offering a wider range and
precision than ‘float’
char
• Size: 16-bit
• Range: 0 to 65,535 (characters in Unicode)
• Used to store a single character.
7
01/03/2025
Booleans
• Size: 1-bit
• Range: true or
false
• Used for
simple flags
that track
true/false
conditions.
8
01/03/2025
Comparison operators.
Reference data types
1.Classes
2.Interfaces
3.Arrays
4.Enums
9
01/03/2025
Classes
• Classes are blueprints for
creating objects. They define a
type by bundling data and
methods that work on the data.
Interfaces
• Interfaces are abstract types
that allow you to define a
contract that classes can
implement. They can contain
method signatures but no
method bodies.
10
01/03/2025
Arrays
• Arrays are containers that hold a fixed number of values of a single
type.
Enums
• Enums are special classes
that represent a group of
constants (unchangeable
variables, like final
variables).
11
01/03/2025
Printing
Parsing command-line arguments.
12