2020-05-03 15:12:03 +02:00
|
|
|
/**
|
|
|
|
* this class is also declared with the public keyword to make it accessible
|
|
|
|
* outside of the current file
|
|
|
|
*/
|
|
|
|
public class Car {
|
2020-05-03 15:12:54 +02:00
|
|
|
|
|
|
|
// define the fields
|
2020-05-03 15:12:03 +02:00
|
|
|
public String model = "";
|
|
|
|
public String manufacturer = "";
|
|
|
|
|
2020-05-04 19:27:23 +02:00
|
|
|
// create the method print_info()
|
2020-05-03 15:12:03 +02:00
|
|
|
public void print_info() {
|
|
|
|
System.out.println("Car Information:");
|
|
|
|
/**
|
|
|
|
* To access fields of the current object the this keyword is used. It is
|
|
|
|
* possible to omit that keyword, but it's recommended to be used anyways.
|
|
|
|
*/
|
|
|
|
System.out.println("- manufacturer: " + this.manufacturer);
|
|
|
|
System.out.println("- model: " + this.model);
|
|
|
|
}
|
|
|
|
}
|