Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package jar2;
- /**
- *
- * @author Janith
- */
- class Student {
- private String name;
- private String ditno;
- private String addr;
- public Student(String n, String d, String a)
- {
- this.name = n;
- this.ditno = d;
- this.addr = a;
- }
- public String getName() { return this.name; }
- public String getAddress() { return this.addr; }
- public String getDIT() { return this.ditno; }
- public void setName(String n) { this.name = n; }
- public void setAddress(String a) { this.addr = a; }
- public void setDIT(String d) { this.ditno = d; }
- public String getDetails ()
- {
- return "I'm a student.\nMy name is "+this.name+".\nI'm from "+this.addr+".\nMy DIT no is "+this.ditno+". ";
- }
- }
- public class Test {
- public static void main(String[] args) {
- Student s1 = new Student("Heshan Perera", "DIT/10/C1/0021", "23, Main Road, Welisara");
- Student s2 = new Student("Inosh Perera", "DIT/10/C1/0064", "53, 1st Lane, Ja-Ela");
- System.out.println(s1.getName());
- System.out.println(s1.getDIT());
- System.out.println(s1.getAddress());
- System.out.println(s2.getName());
- System.out.println(s2.getDIT());
- System.out.println(s2.getAddress());
- System.out.println(s1.getDetails());
- System.out.println(s2.getDetails());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement