티스토리 뷰
Upcasting
Upcasting is casting from a subclass to superclass.
When a superclass variable contains a reference to a subclass object, and that reference is used to call a method, the subclass version of the method is called.
Student s = new Student ();
Person p = (person)s;
↓
Person p = new Student();
Reference variable object
Upcasting happens if you want to reuse your code that knows about the superclass but not the subclass.
reference
'JAVA' 카테고리의 다른 글
Anonymous class in Java (0) | 2019.02.20 |
---|---|
What's the difference between two different List declaration? (0) | 2019.02.02 |
String class in Java (0) | 2019.01.20 |
Collection framework - ArrayList (0) | 2019.01.17 |
abstract & Interface in java (0) | 2019.01.17 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- hackerrank
- repeat()
- easy javascript algorithm
- ... in Javascript
- equals()
- hackerrank javascript solution
- code refactoring
- math.max
- math.abs
- string class in java
- java
- HackerRank Algorithm
- C++
- Javascript Algorithm
- rest parameter
- 프로그래머스
- easy algorithm
- hackerrank javascript
- algorithm
- compareTo()
- hackerrank solution
- Object type casting
- spring boot application
- substring()
- HashMap
- 프로그래머스 알고리즘문제
- javascript
- 프로그래머스 알고리즘
- 알고리즘
- Collection Framework
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함