The static keyword in java is used for memory management mainly. We can apply java static keyword with variables, methods, blocks and nested class.
The static keyword belongs to the class than instance of the class.
Example:-
public Class MyClass
{
public static void main(string[] args)
{
Hello.hello=new Hello();
hello.age=10;
Hello.Dosomething(“Hi CastorClasses”);
}
}
public Class Hello
{
Static int age;
public static string Dosomething(string message)
return message;
}
public string Dosomething(string message)
return message;
}
}
0 Comments:
Post a Comment