本帖最后由 刘国涛 于 2013-3-14 07:47 编辑
- public class Student
- {
- private String name;
- private int age;
- Student(String name,int age)
- {
- this.name = name;
- this.age = age;
- }
- public void setName(String name)
- {
- this.name = name;
- }
- public String getName()
- {
- return name;
- }
- public void setAge(int age)
- {
- this.age = age;
- }
- public int getAge()
- {
- return age;
- }
- }
- public class StudentDemo
- {
- public static void main(String[] args)
- {
- Student s=new Student("zhangsan",20);
- System.out.println(s.getName()+","+s.getAge());
- }
- }
复制代码
怎么声明啊?
|