class Employee {
int DOB;
int eid;
String name;
double salary;
System.out.println(\"Employee class\");
}
If I write the
Don't think about a Java class as something that gets executed in order, every line is read in. Think about a Class as a fancy tool. Like
public class Bathtub {
private int waterLevel;
public void drain() {
waterLevel = 0;
}
public void fill(int newWater) {
waterLevel += newWater;
}
public void playWithDuckies() {
System.out.println("Whee this is fun!!");
}
}
Each method is something you can do with the Bathtub. Think about Swiss-Army-Knife, you have the scissors, the knife, the tweezers, the corkscrew. Each one does a purpose when you call it.
If you put System.out.println()
outside one of these tools, you don't know when it would happen or what would make it happen or what tool it's a part of.