I have two classes that I am compiling from command line.
One is Vehicle class,
class Vehicle{
int passangers;
int fuelcap;
int mpg;
}
and another is VehicleDemo class. This class instantiate an object of Vehicle class.
class VehicleDemo{
public static void main(String args[]){
Vehicle minivan = new Vehicle();
int range;
minivan.passangers = 100;
minivan.fuelcap = 16;
minivan.mpg = 21;
range = minivan.fuelcap * minivan.mpg;
System.out.println("Minivan can carry " + minivan.passangers + " with a range of " + range);
}
}
Since they are in two seperate files I thought I'd have to compile them seperately. But, when I complie VehicleDemo.java it automatically complies Vehicle.java too.
How does java do it? Why it just doesn't raise a flag saying it can't find vehicle class.