Skip to content

Commit

Permalink
Java starter exercise reworked
Browse files Browse the repository at this point in the history
  • Loading branch information
vogella committed Apr 2, 2015
1 parent c7f6efb commit 58aa2c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Expand Up @@ -7,8 +7,8 @@ public static void main(String[] args) {
// I set the age of the person to 32
pers.setAge(32);

// Just for testing I write this to the console
System.out.println(pers.toString());
// this calls the toString method on the pers object
System.out.println(pers);
/*
* Actually System.out.println calls always toString, if you do not
* specify it so you could also have written System.out.println(pers);
Expand Down
Expand Up @@ -46,13 +46,9 @@ public void setAddress(Address address) {
this.address = address;
}

void writeName() {
// Writes the firstname
System.out.println(firstName);


// Alternatively you can combine strings with +
System.out.println(firstName + " " + lastName + "" + age);
@Override
public String toString() {
return firstName + " " + lastName;
}

}

0 comments on commit 58aa2c6

Please sign in to comment.