Say I have two classes, First and Second. In Second I've written a method as follows:
public static void hWorld(){
System.out.println("Hello World!");
}
Then from the main method in the First class I instantiate the Second class and call the hWorld method with:
Second get = new Second();
get.hWorld();
Why couldn't I simplify this by making the hWorld method non-static as follows:
public void hWorld(){
System.out.println("Hello World!")
}
Then from the main method in the First class I call hWorld with:
Second.hWorld();
I guess I don't completely understand what static is used for and when it's better to use. I know by definition that making a field static, it can be called throughout the class as opposed to just an instance of the field. But in practical terms I'm not seeing or understanding that. Can someone please break it down? Thanks.