-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInheritance.java
More file actions
33 lines (23 loc) · 808 Bytes
/
Inheritance.java
File metadata and controls
33 lines (23 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.ArrayList;
/**
* Inheritance
*/
public class Inheritance {
public static void main(String[] args) {
BankAccount account = new BankAccount(3.0);
account.withdraw(10);
System.out.println(account.getBalance());
SavingsAccount savingsAcct = new SavingsAccount(2.1);
savingsAcct.deposit(500);
savingsAcct.withdraw(10);
System.out.println(savingsAcct.getBalance());
ArrayList<Student> students = new ArrayList<Student>();
students.add(new Student("Paul"));
students.add(new Student("Peter"));
students.add(new Student("Parker"));
students.sort(new StudentComparator());
for (Student student : students) {
System.out.println(student.GetName());
}
}
}