java Program for person class

person class (with get and set methods)
Note: Highlighted code added in this lesson.
package org.totalbeginner.tutorial;
public class Person {
// fields
private String name; // name of the person
private int maximumBooks; // most books the person can check out
// constructors
public Person() {
name = "unknown name";
maximumBooks = 3;
}
//methods
public String getName() {
return name;
}
public void setName(String anyName) {
name = anyName;
}
public int getMaximumBooks() {
return maximumBooks;
}
public void setMaximumBooks(int maximumBooks) {
this.maximumBooks = maximumBooks;
}
}

  © Free Blogger Templates Modic Template by For more Information : click Here

Back to TOP