0% found this document useful (0 votes)
32 views12 pages

Data Structures & Algorithm

The document discusses key concepts in Java programming including identifiers, data types, variables, constants, casting, and the Scanner class. Identifiers must be valid names and cannot contain spaces or begin with numbers. Common data types include String, boolean, int, float, and double. Variables store changing values and are declared with a data type and name, while constants never change once declared using the final keyword. Casting converts between data types. The Scanner class handles user input through methods like next().

Uploaded by

CarLos Babaran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views12 pages

Data Structures & Algorithm

The document discusses key concepts in Java programming including identifiers, data types, variables, constants, casting, and the Scanner class. Identifiers must be valid names and cannot contain spaces or begin with numbers. Common data types include String, boolean, int, float, and double. Variables store changing values and are declared with a data type and name, while constants never change once declared using the final keyword. Casting converts between data types. The Scanner class handles user input through methods like next().

Uploaded by

CarLos Babaran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 12

ITE106 – Data Structures &

Algorithm
Java Programming
Identifiers
• User-defined names for methods, variables,
constants and classes.
Valid Identifiers Invalid Identifiers
MyIdentifierName My Identifier Name
myidentifiername my+identifier+name
my_identifier_name my-identifier-name
_myidentifiername my_identifier’s_name
$myidentifiername my_identifier_&_name
_3names 3names

• An identifier cannot have spaces


• Identifiers cannot begin with a digit/number.
Data Types
Data Type Example/s
String “hello world”
boolean true, false
int ‘A’, ‘z’, ‘\n’, ‘6’
float 63.5
double 73.7

• boolean is a logical data type. In java, it has two possible


values: true or false
Variables
• Variables are identifiers whose values can be
changed. They hold information in our program.

<data_type> <identifier>;

• if you wish to declare a variable with an initial value, the


syntax is:

<data_type> <identifier> =<literal>;


Constants
• Constants are identifiers whose values never
change once declared.

final <type> <identifier> = <literal> ;

• EXAMPLE

final string Student_Bday = “11 – 12 – 1991”


final char gender = “m”;
final double Student_Allowance = 999.99;
Casting
• Casting is the process of assigning a value or
variable of a specific type to a variable of another
type.
Scanner
• Class that handles input from a user. - new is used to
create new
objects from a
class
- create an object
from the
Scanner class

- call a method
- next gets the
next string of text
that a user types
on the keyboard.

You might also like