<언어>/[Java]

[Java] OOP 공부

콜리브리 2022. 2. 7. 16:48

OOP 예시, 실습 많은 자료/책 같은거 없을까

 

 

 

⭐️ Q. Declare with interface VS class?

HashMap<Integer,String> map=new HashMap<Integer,String>(); // HashMap class
Map<Integer,String> map=new HashMap<Integer,String>(); // Map interface

→ Interface, to get the advantage of polymorphism

https://stackoverflow.com/questions/3383726/java-declaring-from-interface-type-instead-of-class

PS 수준에선 로컬 변수를 class로 선언해도 상관 없을 듯 하지만 (딱히 OOP/polymorphism 많이 활용 안하니까), 현업에 적응하기 위해 Interface 활용.

https://stackoverflow.com/questions/7716435/why-would-you-declare-an-interface-and-then-instantiate-an-object-with-it-in-jav

 

 

 

Static class in Java - nested class 만들 때 쓰는 개념?

https://www.geeksforgeeks.org/static-class-in-java/