Java Application/Uses
Desktop
Applications or standalone Applications such as acrobat reader, media player,
antivirus etc.
Web Applications
(Web Applications are those applications which runs on server and you can
create dynamic application using jsp,servlet,struts etc.
Enterprise Applications such as banking applications, insurance etc.
Mobile Application
(Android Apps)
Robotics,
Games.
Software Tools.
Big Data
technologies.
Data
Types in Java
Data types are used to store different values in the
variable. There are two types of data types:
Primitive data types: which include Integer, Character, Boolean, and Floating Point.
Data Type
|
Default Value
|
Default size
|
char
|
'\u0000'
|
2 byte
|
byte
|
0
|
1 byte
|
short
|
0
|
2 byte
|
int
|
0
|
4 byte
|
long
|
0L
|
8 byte
|
float
|
0.0f
|
4 byte
|
double
|
0.0d
|
8 byte
|
boolean
|
false
|
1 bit
|
Non-primitive data types: which include Classes, Interfaces, and Arrays.
Variables:
Variable means whose value can be changed.
Variable contains value which is stored in memory
and holds some space.
Every Variable is assigned a datatype which shows
size(4 byte,8 byte etc.) and type of data type(int,double etc.)
2 steps to use
variables
·
Variable Declaration
·
Variable Initialization
Variable Declaration
Syntax:
Datatype variablename;
Eg: int x;
Where int is the data type and x is the variable name.
Variable Initialization
Syntax:
Datatype variablename=value;
Eg: int x=89;
Where int is the data type, x is the variable name and
89 is the value which assigned to x.
Types
of variables
In Java, there are three types of
variables:
1. Local Variables
2. Instance Variables
3. Static Variables
1) Local Variables
The variables
which are declared inside the body of a method is called as local variables.
2) Instance Variables
Instance variables are a variable that are declared outside a method and
inside a class.
static keyword is not required to declare a instance
variable
3) Static Variables
Static variables
are initialized only once, at the start of the program execution.
A
variable that is declared as static is called static variable.
static
keyword is required to declare a static variable.
These variables
should be initialized first, before the initialization of any instance
variables.
Example:
class Demo{
string name=”LearningPoint92”; //instance variable
static int x=100; //static variable
void display ()
{
int y=90; //local variable
}
}
No comments:
Post a Comment