Java Getter and Setter Work
Here is the Java Programming Program of Getter and Setter from Miss Aisha Khan.Note : This is Program not Presentation or PDF Kindly Understand the code and Work. Can Ask Anytime for help.
Student Class :
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package gettersetter;
/**
*
* @author asp
*/
public class Student {
int id,age;
String name;
public int getid(){
return id;
}
public String getname(){
return name;
}
public int getage(){
return age;
}
public void setid(int i){
id=i;
}
public void setname(String n){
name=n;
}
public void setage(int a){
age=a;
}
}
Main Class();
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package gettersetter;
/**
*
* @author asp
*/
public class GetterSetter {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Student std=new Student();
std.setid(45);
std.setname("Owais");
std.setage(20);
System.out.println(std.getid());
System.out.println(std.getname());
System.out.println(std.getage());
}
}
0 comments:
Post a Comment