How to Static variables can be invoked by class method

package sample;

/**
 *
 * @author A.Subash
 */
public class sample3 {
   
static int a=5,b=6,c;
    void abc()
    {
        c=a+b;
        System.out.println("Sum="+c);
    }
    public static void main(String aasgs[])
    {
        sample3 s1=new sample3();
        s1.abc();
    }
}

/*
O/P:
Sum=11
*/

No comments:

Post a Comment

Thank you for using this blog.