Yeon's Frame
  • Intro
  • Project
    • 미소웨더
      • 기획 - 아이디어 및 유스케이스 정리
      • DB 설계 - JPA 활용 중심
  • Study
    • Spring
      • Spring Feature
      • N+1
      • OSIV
      • @Valid
      • Spring Boot Feature
      • Spring 5 Feature
      • JPA vs MyBatis
      • Filter, Interceptor
      • Persistence Context
      • @Transactional
      • @Controlleradvice, @ExceptionHandler
      • Spring Security
      • Dispatcher Servlet
      • @EnableWebMvc
      • Stereo Type
      • AOP
      • JPA Repository
    • Infrastructure
      • Git
      • DNS
      • JWT
      • DevOps
      • Docker
      • Jenkins
      • Cloud Computing
      • MSA
    • Clean Code
      • 깨끗한 코드
      • 의미있는 이름
      • 함수
      • 주석
      • 형식 맞추기
      • 객체와 자료구조
      • 오류 처리
      • 경계
      • 단위테스트
      • 클래스
      • 시스템
  • Basic
    • Java
      • OOP
      • OOL Features
      • Class & Objects
      • Instance & Heap Memory
      • Constructor
      • Reference Type Uses
      • Access Modifier & Hiding
      • This
      • Collaboration
      • Static
      • Inheritance
      • Polimorphism & Casting
      • Abstract Class
      • Interface
      • Object Class
    • Java Coding
      • JVM
      • String, StringBuffer, StringBuilder
      • SOF
      • Blockcing/NonBlocking
      • Enum
      • Static
      • Thread
      • hashCode() | equals()
      • JDK8
      • Stream
      • Optional
      • Lambda & Closure
      • Exception
      • Garbage Collecter
      • Collection
      • Call by Value & Call by Reference
      • Generic
    • Java_Advance
      • Inner Class
      • Lambda Expression
      • Functional Interface
      • OOP vs Lambda Expression
      • Stream
      • Reduce()
      • Exception Handling
      • Custom Exception
      • Error Log
      • IO Stream
      • IO Stream - Serialization
      • File Class
      • Decorator Pattern
      • Thread
    • Data Structure
      • Intro
      • Generic(1)
      • Generic(2) T extends
      • Generic(3) Method
      • Collection Frameworks
      • List
      • Iterator
      • Set
      • Comparable & Comparator
      • Map
  • Practice
    • Algorithm
      • Strategy
        • Primitive, Reference, Generic
        • Number Data Types
        • For-Each
        • Array, Queue, ArrayDeque
        • Array vs ArrayList
Powered by GitBook
On this page
  • Primitive Type vs Reference Type (Using Wrapper Class)
  • Generic 에서의 Primitive Type vs Reference Type
  • Primitive Type Array
  • Generic using Reference Type
  1. Practice
  2. Algorithm
  3. Strategy

Primitive, Reference, Generic

Primitive Type vs Reference Type (Using Wrapper Class)

  • Primitive Type 의 속도가 월등히 빠르다.

  • Generic 에는 Primitive Type 사용이 불가하다.

Generic 에서의 Primitive Type vs Reference Type

Primitive Type Array

ArrayDeque<Integer> deque1 = new ArrayDeque<>();
deque1.add("qwer");
deque1.add(1); 
deque1.add('b'); 

for (Object o : deque1){
    int x = (int)o; // String -> int 변환에서 에러가 발생한다.
    System.out.println(x);
}
  • 런타임 에러가 발생한다.

Generic using Reference Type

ArrayDeque<Integer> deque2 = new ArrayDeque<>();
deque2.add("qwer"); // Syntax Error
deque2.add(1); // CORRECT
deque2.add('b'); // Syntax Error

for (Object o : deque1){
    int x = (int)o; 
    System.out.println(x);
}
  • Syntax 에러를 통해서 컴파일 이전에 에러가 있음을 알 수 있다.

  • 프로그램 실행 자체가 불가능하다.

PreviousStrategyNextNumber Data Types

Last updated 2 years ago