Basic program

This is fist program from which each developer start their journey of learning java

       ------------------------------------------------------------STATIC VARAIBLES-----------------------------------------------
 EXAMPLE 1:
 
class demo{
 
  static int x=5;
  
  public static void main(String args[]){
    	   System.out.pritnln(x);
		}
  }
  
  
          

         OUTPUT:  5
          

        EXAMPLE 2:

class student{

   int id;
   String name;
   String coaching="abc";
   
   student(  int i,String n){
         id =i;
	     name=n;
    }
   
   void show(){
      System.out.println(id+" "+name+" "+"coaching");
	  	 }

  public static void main(String args[]) {
     student s=new student(1,"shoyab");
     s.show();
	 student s1=new student(2,"Vatsal");
	 s1.show();
	 student s2=new student(3,"Sunny");
	 s2.show();
	 student s3=new student(4,"Pooja");
	 s3.show(); 
  
  
  }
} 
          

         OUTPUT:
  
1 shoyab abc
2 Vatsal abc
3 Sunny abc
4 Pooja abc
        
          

         
  --------------------------------------------------------STATIC METHOD------------------------------------------------------
  //static method always call static method otherwise reflect compile time error
  
  Example:1---static method access non static varaible --throw compile time error    
   
class demo {
	int x=5;
	public static void main(String args[]){
	System.out.println(x);
	}
}

  
  

          

       OUTPUT:
   
   Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
	Cannot make a static reference to the non-static field x

	at demo.main(demo.java:7)
          

        class student{

   int id;
   String name;
 static  String coaching="abc";
   
   student(  int i,String n){
         id =i;
	     name=n;
    }
   
   static void change(){
	   
	   coaching="bhanu";
   }
   
   void show(){
      System.out.println(id+" "+name+" "+coaching);
	  	 }

  public static void main(String args[]) {
	  
	  student.change();
	  
     student s=new student(1,"shoyab");
     s.show();
	 student s1=new student(2,"Vatsal");
	 s1.show();
	 student s2=new student(3,"Sunny");
	 s2.show();
	 student s3=new student(4,"Pooja");
	 s3.show(); 
  
  
  }
} 
       
          

     OUTPUT:

1 shoyab bhanu
2 Vatsal bhanu
3 Sunny bhanu
4 Pooja bhanu
  
          

   -------------------------------------------------------------------------STATIC BLOCK--------------------------------------------

public class demo {
	static {
		  System.out.println("Hello");
	}
	
	public static void main(String args[]){
		
		System.out.println("Everyone");
	
	}
	
}
          

    OUTPUT:

Hello
Everyone
          

Now discuss on keywords which used here:

Public: It is Access Specifier

Static: static is keyword,it is part of class

void : void is return type

main(String args[]): It is method from Which JVM start reading code

System.out.println():It is used for print data on console

Address

Plot number-56/1
Near Gurudwara
LandMark :
Opposite A.N.D college
Govindpuri Metro station
New Delhi
Mobile number:
8826034620