0
How can this statement be true? I mean how can I implement it?
In my book it is written that when the main method is not included the execution of the class program can be done through creating objects?
3 Respuestas
+ 4
Imagine you have a class Dog:
public class Dog{
public void bark(){
System.out.println("woof");
}
}
This class itself does nothing.
But in your class with the main method you can do this:
Dog myDog = new Dog();
myDog.bark();
0
Yes that is what I am saying it will show no output. That means the statement written in the book is wrong?
0
Atul
I am not sure what you have tried but my example works as expected:
https://code.sololearn.com/cTKVhrJttHVl/?ref=app