Static are the members or variables which are defined independently of any object of that class. Static members are the members that can be used by itself, without reference to a specific instance. We can declare both methods and variables to be static. The variables declared as static are global variables. When objects of the class are declared, no copy of a static variable is made. Instead, all instances of the class share the same static variable.
Methods declared as static have several restrictions:
1. They can only call other static methods.
2. They must only access static data.
3. They cannot refer to this or super.
If we need to do computation in order to initialize the static variables, we can declare a static block which gets executed exactly once, when the class is first loaded.
static int SrNo=1;
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
int RollNo = SrNo;
System.out.println("Enter Name of a Student : ");
System.out.println("Enter Science Marks ");
System.out.println("Enter Math Marks ");
System.out.println("Roll Number :"+ RollNo);
System.out.println("Name : "+Sname);
public static void main(String args)
StudentDetail STD=new StudentDetail;
System.out.println("Enter the Details of Three Students");
STD[i]= new StudentDetail();
System.out.println("The Details of Three Students Entered are :");