3个回答
展开全部
包名改成你自己的
package test;
public class Student {
private int no;
private String name;
private int age;
private int count;
public Student(int no,String name,int age) {
this.no=no;
this.name=name;
this.age=age;
count++;
}
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
@Override
public String toString() {
return "学号:" + no + " 姓名:" + name + " 年龄:" + age;
}
public static void main(String[] args) {
Student stu=new Student(1,"zhangsan",22);
System.out.println(stu.toString());
stu.setName("lisi");
stu.setAge(25);
System.out.println(stu.toString());
}
}
展开全部
Public Class Student
{
private string no;
private string name;
private int age;
private static int count = 0;
Public Student(string no,string name,string age)
{
this.no = no;
this.name = name;
this.age = age;
count++;
}
public void setNo(string no)
{
this.no = no;
}
public string getNo()
{
return this.no;
}
public void setName(string name)
{
this.name = name;
}
public string getName()
{
return this.name;
}
public void setAge(string age)
{
this.age = age;
}
public string getAge()
{
return this.age;
}
public string toString()
{
return "no:"+this.no+",+name:"+this.name+",age:"+this.age;
}
public int getCount()
{
return count;
}
public static void main(string[] args)
{
Student stu = new Student("1205107777","Merle",10);
Student stu2 = new Student("1205107778","JACK",15);
system.println("Info of Student1:"+stu.toString());
system.println("Info of Student2:"+stu2.toString());
}
}
{
private string no;
private string name;
private int age;
private static int count = 0;
Public Student(string no,string name,string age)
{
this.no = no;
this.name = name;
this.age = age;
count++;
}
public void setNo(string no)
{
this.no = no;
}
public string getNo()
{
return this.no;
}
public void setName(string name)
{
this.name = name;
}
public string getName()
{
return this.name;
}
public void setAge(string age)
{
this.age = age;
}
public string getAge()
{
return this.age;
}
public string toString()
{
return "no:"+this.no+",+name:"+this.name+",age:"+this.age;
}
public int getCount()
{
return count;
}
public static void main(string[] args)
{
Student stu = new Student("1205107777","Merle",10);
Student stu2 = new Student("1205107778","JACK",15);
system.println("Info of Student1:"+stu.toString());
system.println("Info of Student2:"+stu2.toString());
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2017-06-12
展开全部
public class Student{
private String no;
private String name;
private String age;
public Student(String no,String name,String age){
this.no=no;
this.name=name;
this.age=age;
}
.
.
.
.
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询