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 :: convert string array to string 
Java :: java hex to rgb 
Java :: format specifier in java 
Java :: GridLayout 
Java :: navigation graph setup android 
Java :: splash full screen android 
Java :: how do you handle exceptions in java 
Java :: Java Iterating through LinkedList 
Java :: POST method) in spring rest api 
Java :: why we use return method 
Java :: java application 
Java :: java spring mvc 
Java :: nested class in java 8 
Java :: join strings in java 
Java :: focusbutton 
Java :: int to integer array in java 
Java :: if else bedingungen java 
Java :: prefix vs postfix increment java 
Java :: bukkit how to make a cancelable event 
Java :: how to create a sublist in java 
Java :: Kadane Algorithm for maximum sub-array 
Java :: gson to class 
Java :: longest subarray with equal 0 and 1 
Java :: sysout is not working in eclipse 
Java :: SmallChange 
Java :: how to use asynx task to make api connection java 
Java :: javax.servlet.Filter 
Java :: android studio setbackgroundcolor drawable 
Java :: firebase persistence enable android 
Java :: javadoc generate docs for files in folder and subfolders 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =