You are on page 1of 12

Java Project

Class
It is a collection of data members, member functions constructors and code blocks.
Class also contains different objects.
Variables
• It is a piece of memory which I used to store information.

• One variable can store one information at a time.

How to declare and then initialize variable


declaration
Syntax  dataType variable_Name;
initialization
variable_Name = variable_value;

How to declare and initialize at same time

Syntax  dataType variable_Name = variable_value;


Example

1)
int a;
int a = 10;
a = 10;

2)
String b;
String b = “Velocity Classes”;
b = “Velocity”;

• Variable name should not start with numeric

• Variable name should start with small letter


dataType variable_Name = VariableValur;

Data type
• Data type are used to represent type of data or information which we are going
to use in our java program.

• In java programming it is mandatory to declare data type before declaration of


variable.

Types
1) Primitive datatype (Keyword)

2) Non-primitive datatype (identifires)


bit
bit

bit

bit
bit

bit
bit

bit
Example
Storage Capacity of byte

Byte  1 byte  8 bites

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 1

0 0 0 0 0 0 1 1

0 0 0 0 0 0 1 0

Possible number of combination  2 ^ 8  256

-128 127
0
Example

Storage Capacity of char  2 bytes  16 bits  2^16  65563 characters


Operators in java
It is a special type of symbols used to perform actions on variable or to compare two or more statements.

1) Arithmetic operator  (Mathematical function that takes two operands and perform action on them)

2) Logical operator  (Performs operation in two conditions)

3) Relational operator  (Shows relation between two conditions)

1) Arithmetic operator
• Addition  +
• Subtraction  -
• Multiplication  *
• Division  /
• Mod  %
• Increment  ++
• Decrement  --
2) Logical operator

• AND  &&  Need to fulfill both conditions


• OR  ||  Need to fulfill any one of condition
• NOT  !  Not to fulfill given condition

3) Relational operator

• Greater than >


• Less than <
• Equal to ==
• Greater than or Equal to >=
• Less than equal to <=
• Not Equal to !=
2) Assignment operator

• Assignment Operator =  To assign value of 1 variable to another variable.

You might also like