We Offer 100% Job Guarantee Courses (Any Degree / Diploma Candidates / Year GAP / Non-IT / Any Passed Outs). Placement Records
Hire Talent (HR):+91-9707 240 250

General

Static Keyword in Java

Static Keyword in Java

Static Keyword in Java

Static key word by using we can declare variables ,methods and blocks. These static variables , methods and blocks we can access or call directly with out creating object. It means static it is class level.

Example 1:

Public class Test{
Static int i =10;
}

The above static variable in another class we can call directly with out creating the object.

Test.i; in this way we can call.

Example 2:

Public class Test{
Public static void getDetails(){
System.out.println(“static method”);
}
Static{
System.out.println(“static block”);
}
}

The above class declared static block and static method. the static block will execute directly wile creating an object before created all static blocks will execute. The static method we can call directly with these class reference with out creating an object.

Click Here-> Get Java Training with Real-time Projects

Besant Technologies WhatsApp