So, I'm pretty new to Java, and as far as I can see, both of these are the same things:
public class HelloWorld {
public void test(String test) {
System.out.println(test);
}
public static void main(String args[]) {
HelloWorld helloworld = new HelloWorld();
helloworld.test("Hello world!");
}
}
and
public class HelloWorld {
public static void test(String test) {
System.out.println(test);
}
public static void main(String args[]) {
test("Hello world!");
}
}
Are these both the same thing, and what's the reason you would use one over the other?