Skip to content

Instantly share code, notes, and snippets.

@fkaa
Created June 9, 2014 15:17
Show Gist options
  • Select an option

  • Save fkaa/54e290f5796714eca268 to your computer and use it in GitHub Desktop.

Select an option

Save fkaa/54e290f5796714eca268 to your computer and use it in GitHub Desktop.
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