第一个代码:
package cn.bdqn.demo04;
public class Lianxi3 {
String course;
double hour;
String teacher;
public void print(){
System.out.println("课程名是:"+course);
System.out.println("学时是:"+hour);
System.out.println("任课老师是:"+teacher);
}
}
第二个代码:
package cn.bdqn.demo04;
public class Lianxi33 {
public static void main(String[] args) {
Lianxi3 cyuyan = new Lianxi3();
cyuyan.course = "c语言";
cyuyan.hour = 100;
cyuyan.teacher = "张三";
cyuyan.print();
System.out.println();
Lianxi3 java = new Lianxi3();
java.course = "java编程";
java.hour = 100;
java.teacher = "张三";
java.print();
System.out.println();
Lianxi3 php = new Lianxi3();
php.course = "php网络编程";
php.hour = 100;
php.teacher = "张三";
php.print();
System.out.println();
Lianxi3 c = new Lianxi3();
c.course = "c++";
c.hour = 100;
c.teacher = "张三";
c.print();
System.out.println();
Lianxi3 shuju = new Lianxi3();
shuju.course = "数据结构";
shuju.hour = 100;
shuju.teacher = "张三";
shuju.print();
System.out.println();
}
}
双击加关注啊,兄弟们!!!!