JAVA程序编写一个学生类Student

2024-10-29 07:29:52
推荐回答(4个)
回答1:

Public Class Student{
Public long id;
Public String name;
Public int age;
Public boolean sex;
Public long phone;
Public Student(long i,String n,int a,boolean s,long p){
this.id = i;
this.name = n;
this.age = a;
this.sex = s;
this.phone = p;
}
Public int getage(){
return this.age;
}
Public long getphone(){
return this.phone;
}
Public String toString(){
return this.name;
}
Public static void main(String[]args){
Student student = new Student(01,"李明",20,true,13xxx);
System.out.println(student.age());
System.out.println(student.getphone());
System.out.println(student.toString());
}
}

回答2:

//以下是程序段在自己机子上已经编译运行过了你自己试下
public class Student{
public long id;
public String name;
public int age;
public boolean sex;
public long phone;
public Student(long i,String n,int a,boolean s,long p){
this.id = i;
this.name = n;
this.age = a;
this.sex = s;
this.phone = p;
}
public int getage(){
return this.age;
}
public long getphone(){
return this.phone;
}
public String toString(){
return this.name;
}
public static void main(String[]args){
Student student = new Student(01,"李明",20,true,8888);
System.out.println(student.getage());
System.out.println(student.getphone());
System.out.println(student.toString());
}
}

回答3:

咋不自己写呢

回答4:

no