复习java6

xiaoxiao2021-02-28  73

package com.company; /** * Created by henson on 17-8-28. */ public class Student extends Person{ String school; int score; void sayHello(Student another){ System.out.println("Hi"); if (school==another.school) System.out.println("We are Schoolmates"); } boolean isGoodstudent(){ return score>90; } void testThisSuper(){ int a; a=age; a=this.age; a=super.age; } void sayHello(){ super.sayHello(); System.out.println("My school is "+school); } Student(String name,int age,String school){ super(name,age); this.school=school; System.out.println("Hello! Student(String name,int age,String school)"); } Student(){ System.out.println("Hello! Student()"); } public static void main(String[] args){ //Person p=new Person("LingMing",50); //Student s=new Student("WWQ",18,"PKU"); Person p2=new Student("Zhangyi",20,"THU"); // Person p3=new Student("Zhangyi",20,"PKU"); Student s2=(Student)p2; //Student s3=(Student)p3; // p.sayHello(); // s.sayHello(); //p.sayHello(s); //s.sayHello(s3); } }

写继承类的时候,果然忘了有些参数了,IDEA太好用了,有依赖性,有毒。 打脸了要做笔记。

关于抓取:用 try except 错误的语句 忽略进入下一步 或者将它循环

转载请注明原文地址: https://www.6miu.com/read-97247.html

最新回复(0)