✨
Java
  • 자바의 역사
  • Ch1
    • Before Start Java
      • History of Java
      • Feature of Java
      • API Documentation
      • Hello World!
      • eclipse shortcut
      • Eclipse IDE
      • GitHub to eclipse
  • Ch2
    • Variable
      • Variable
    • Variable Type
    • Character and String
    • Primitive type and range
    • printf and formatter
    • Scanner
    • Overflow of Int
    • Transition between different variable types
    • Object Array
  • CH3
    • Operator
  • CH4
    • 조건문과 반복문
    • if statement
    • switch
    • Math.random()
    • for statement
    • while statement
    • break, continue, named iterated statement
  • CH5
    • Array
    • 배열 활용
    • String Array
  • OOP
    • Intro
  • Class and Object
  • Make multiple Classes in one file
  • How to use Object
  • Object Array
  • Variable type according to declared location
  • Class Variable and Instance Variable
  • Method
  • Call Stack
  • Parameter
  • Static method(Class method) and Instance method
  • (Method)Overloading
  • Constructor
  • Constructor this()
  • Reference type variable "this"
  • Initialize variable
  • Inheritance
  • Composite
  • Single Inheritance, Object Class
  • (Method)Overriding
  • super, super()
  • package, class path
  • import, static import
  • modifier
  • access modifier
  • Encapsulation
  • Polymorphism
  • reference type transition
  • instanceof operator
  • Parameter polymorphism
  • Multiple object using one array
  • Abstract Class, Abstract Method
  • Creating Abstract Class
  • Interface
  • Interface Polymorphism
  • Interface Pros
  • Default method and static method
  • Inner Class
  • Anonymous Class
  • java.lang package and useful class
    • Object class
    • hashCode(), toString()
    • String class
    • StringBuffer class
    • StringBuilder class
    • Math class
    • Wrapper class
    • Number class
    • String to Number, String to Wrapper class
    • Auto-boxing and (auto)Unboxing
  • Collection Framework
    • Collections framework
    • List, Set, Map Interface
    • List의 removeAll() 과 clear() 비교
    • List Interface - ArrayList
    • How to view Java API source
    • List Interface - LinkedList
    • Stack and Queue
    • Iterator, ListIterator, Enumeration
    • Array
    • Comparator와 Comparable
    • Stack
    • String
    • String + char = String
    • String.toCharArray()
    • BufferedReader / BufferWriter
    • Scanner로 String 입력 - next( )와 nextLine( )
    • 공백없이 2차원배열 데이터 String으로 한번에 한줄씩 입력받기(문자/숫자)
    • 공백을 사이에 두고 빠른 2차원 배열 입출력
    • arr[index++]과 arr[index] index++의 차이
    • int와 long의 차이
    • Untitled
    • 타입 간의 변환
    • Array 와 ArrayList
    • valueOf()
    • Char
    • 변수, 객체 초기화(초기값 설정)
  • error troubleshooting
    • No enclosing instance of type
    • ASCII Code Table
    • java.lang.NumberFormatException
    • No enclosing instance..
  • reference
    • String을 생성하는 2가지 방법과 차이점
    • StackOverflowError(스택, 힙 메모리)
    • swtich-case 반복문
Powered by GitBook
On this page

Was this helpful?

  1. Ch2

Overflow of Int

코딩테스트에서 값의 범위를 참고하여 오버플로우하지 않도록 형을 고려하면 되겠다! ex) 우아한 테크코스 테스트 문제 중. 돈 담을 지갑이 최대한 가볍도록 큰 금액의 화폐위주를 선택할 때. 변수 money는 1이상 1,000,000 이하인 자연수.

Overflow : 표현가능한 범위를 넘는 것.

최댓값 + 1 = 최솟값, 최댓값 = 최솟값 -1

ex) 십진수 9999 + 1 = 0000(최솟값), 0000 - 1 = 9999(최댓값)

이진수 1111 + 1 = 0000(최솟값), 0000 - 1 = 1111(최댓값)

부호없는 정수(4bit)의 경우, 표현 범위가 '0~15' 이므로 이 값이 계속 반복되고, 부호있는 정수(4bit)의 경우, 표현 범위가 '-8부터 7' 이므로 이 값이 무한히 반복된다.

ex) 0 ~ 15 : 15(M) + 1 = 0(m), 0(m) - 1 = 15(M)

-8 ~ 7 : 7(M) + 1 = -8(m), -8 - 1 = 7(M)

n bit 표현 범위

n bit의 2진수 표현 범위 : 2^(bit수) - 1

ex) 2bit : 00(0),01(1),10(2),11(3) => 2^(2) - 1.

16bit : (2^16)-1 = 65536개

short 타입의 표현 범위 : 2byte = 2 x 8bits = 16bits. 부호 있는 타입이므로 -2^15 ~ (2^15)-1

char 타입의 표현 범위 : 2byte = 2 x 8bits = 16bits. 부호 없는 타입이므로 0 ~ (2^16)-1

PreviousScannerNextTransition between different variable types

Last updated 4 years ago

Was this helpful?