You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
704 B

class Student{
String studentId;
String name;
double score;
//define a study approach
void study() {
System.out.println(studentId+" "+name+"正在学习,上一次的成绩是"+score);
}
}
public class Main {
public static void main (String[] args) {
//setting up the first object
Student s1=new Student();
s1.studentId="001";
s1.name="George";
s1.score=90;
//setting up the second object
Student s2=new Student();
s2.studentId="002";
s2.name="Roya";
s2.score=95;
//using the approach study()
s1.study();
s2.study();
}
}