Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Student{
- private String name;
- private int id;
- private String address;
- public Student(){
- name = "";
- id = 0;
- address = "";
- }
- public String getName(){
- return name;
- }
- public int getID(){
- return id;
- }
- public String getAddress(){
- return address;
- }
- public void setName(String n){
- name = n;
- }
- public void setID(int i){
- id = i;
- }
- public void setAddress(String a){
- address = a;
- }
- }
- public static void main(String[] args){
- Student stu1 = new Student();
- stu1.setName("Bob");
- stu1.setID(10110);
- stu1.setAddress("123 Main St");
- System.out.println("Name: " + stu1.getName());
- System.out.println("ID: " + stu1.getID());
- System.out.println("Address: " + stu1.getAddress());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement