What does static
mean?
I know public
means that it can be accessed from outside the class, and private
only from inside the class…
Example:
public class Methods_Test1
{
public static void Display(String Name)
{
System.out.println("Hello There " + Name);
System.out.println("I am from Display method");
}
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter name");
String name = sc.next();
Obj.Display(name);
}
The public static void Display(String name) method accessible as static method within its own class which can be accessed without creating object of the class where as the same method behaves as public for the outside classes which can be accessed by creating object.