Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

static block in java

Static block is used for initializing the static variables.
This block gets executed when the class is loaded in the memory. 
A class can have multiple Static blocks
Comment

what is use of static block in java

Static block is run immediately its loaded into memory(ie.,when class is 
loaded into class loader), not when class is 
created like a constructer. Its mostly used to initialize static variables
created in a class.
Comment

static block in java

It is used to create another block before the main class.
  every java codes runs here first.
  Any code gets executed before the main class
    
    static{
    //code is placed between these brackets.
  }
Comment

static block in java

// to create static block in java 
static{
  // code to be executed is placed here
}

// its placed inside class. its executed whenever the class is created not when its object is created or called.
Comment

PREVIOUS NEXT
Code Example
Java :: how to acces every char of a String in java 
Java :: java bigdecimal check less zero 
Java :: android dialog 
Java :: why are there no destructors in java? 
Java :: android studio change title bar text 
Java :: JAVA HashMap get keys by values 
Java :: android studio change menu title 
Java :: entity cannot be resolved to a type in spring boot eclipse 
Java :: java format use same value multiple times 
Java :: how to make a copy of an array java 
Java :: kjk;ok 
Java :: how to add 2 numbers in java 
Java :: android list index 
Java :: Who is James Gosling 
Java :: keytool error: java.io.FileNotFoundException: c:UsersUSER_NAMEupload-keystore.jks (The system cannot find the path specified) 
Java :: input array in String in java 
Java :: how to use deque as queue in java? 
Java :: filtering out unique values from a list in java 
Java :: activitycompat.requestpermissions not working 
Java :: dark mode app android studio 
Java :: print java 
Java :: java eclipse console clear 
Java :: list files in directory java 
Java :: how to find numbers of digits in java 
Java :: viewpager androidx dependencies 
Java :: java enums 
Java :: java print statement 
Java :: java booleans 
Java :: string to int 
Java :: java.lang.string cannot be cast to java.lang.double react native 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =