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.
27 lines
688 B
27 lines
688 B
//定义Student类
|
|
class Student{
|
|
//属性:学号、姓名、分数
|
|
String studentld;
|
|
String name;
|
|
double score;
|
|
void study(){
|
|
System.out.println(name+"编写代码");
|
|
}
|
|
}
|
|
//主类
|
|
public class Main{
|
|
public static void main(String[] args){
|
|
//实例化第一个对象
|
|
Student s1=new Student();
|
|
s1.studentld="001";
|
|
s1.name="张秋实";
|
|
s1.score=3.96;
|
|
s1.study();//调用study方法
|
|
//实例化第二个对象
|
|
Student s2=new Student();
|
|
s2.studentld="002";
|
|
s2.name="高一栋";
|
|
s2.score=6.25;
|
|
s2.study();//调用study方法
|
|
}
|
|
}
|