Commit 43a72ddb by Patryk Czarnik

jakieś poprawki w polimorfizmach

parent b742211d
......@@ -48,6 +48,7 @@ public class Polimorfizm1 {
System.out.println(ktos.getClass());
// Aby sprawdzić, czy rzutowanie będzie możliwe, używamy instanceof:
// Gdyby w zmiennej ktos był obiekt klasy StudentInformatyki, to też wyszłoby true
if(ktos instanceof Student) {
// rzutowanie jest bezpieczne
System.out.println( ((Student)ktos).rok );
......@@ -70,7 +71,6 @@ public class Polimorfizm1 {
System.out.println(student.oceny);
System.out.println(student.sredniaOcen());
System.out.println(((Student)ktos).sredniaOcen());
}
}
......@@ -8,6 +8,10 @@ public class Student extends Osoba {
int rok;
List<Integer> oceny = new ArrayList<>();
{ System.out.println("init Student"); }
static { System.out.println("static Student"); }
public Student() {
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment