Last active
December 14, 2015 19:58
-
-
Save samiron/5140275 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
| class Person | |
| { | |
| private String name ; | |
| private int id; | |
| /** | |
| * Receives the name and set in instance variable | |
| */ | |
| public void setName(String name){ | |
| this.name = name; | |
| } | |
| /** | |
| * Returns the name of the instance | |
| */ | |
| public String getName(){ | |
| return this.name; | |
| } | |
| /** | |
| * Receives id and set in instance variable | |
| */ | |
| public void setId(int id){ | |
| this.id = id; | |
| } | |
| /** | |
| * Returns the id of the instance | |
| */ | |
| public int getId(){ | |
| return this.id; | |
| } | |
| } | |
| public class StudentTester | |
| { | |
| public static void main(String[] args) | |
| { | |
| Person john = new Person(); | |
| john.setName("Johnty Rhodes"); | |
| john.setId(11); | |
| System.out.println(john.getName()); | |
| System.out.println(john.getId()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment