Topic 3: Basic Java Features (Part 1)
Topic 3: Basic Java Features (Part 1)
Basic
Java Features (Part 1)
sufian, marini,
norleyza, noor faezah
Objectives
Use constants and variables
Learn about primitive data types
Write arithmetic statements
Understand numeric type conversion
Use the JOptionPane class for GUI input and output
Constants and Variables
Constant: value stays fixed after compilation
Constants may be assigned symbolic name
Constant's literal value may be used directly
eg: 3.14F
Without the F, it is assumed as a double
The type double is the default of real numbers in Java
The ending D can also be used for type double, eg:
3.14D
Floating-point division returns floating-point value
Floating-Point Data Types
Example: 45 % 35 = 10
// this is a comment
We can also comment out a block of program using /* and
*/ as follows:
/* This is also a comment */
Automatically Generated Documentation
&& AND
|| OR
! NOT
^ EXCLUSIVE OR