Created
June 9, 2014 15:17
-
-
Save fkaa/54e290f5796714eca268 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Car { | |
| public String brand; | |
| public int year; | |
| public Car(String brand, int year) { | |
| this.brand = brand; | |
| this.year = year; | |
| } | |
| @Override | |
| public String toString() { | |
| return String.format("Car: [brand: %s, year: %s]", this.brand, this.year); | |
| } | |
| } | |
| void main() { | |
| Car car = new Car("bmw", 2007); | |
| System.out.println("The car is a " + car.brand); | |
| System.out.println("The car is from " + car.year); | |
| //debug (check if values are what they are supposed to be) | |
| System.out.println(car); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment