Program to demonstrate static variables, methods

/* Program to demonstrate static variables, methods */

class StaticDemo
{
    static int i = 1;
    static int j = 5;

    static void display( )
    {
        System.out.println(" i = "+i);       
    }
   
}
class StaticDemo2
{
    public static void main(String args[])
    {   
        StaticDemo.display();
        System.out.println(" j = "+StaticDemo.j);   
    }
}
       

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|