DS Lec.2 - Java Basics 2

Nitroblue 1·2025년 9월 29일

자료구조

목록 보기
7/15

시험이 이틀 뒤인만큼 너무 자료구조 과목과 거리감있는 공부는 지양하기로.. 빠르게 훑고 넘어가자.

Array

int[] a;				// array declaration
a = new int[2];			// length specification
int[] b = {1, 2, 3, 4};	// array declaration with assignment
int bLength = b.length;	// get the length of an array

Operators

(smooooth operrrration~~)

  • Arithmetic operators : +, -, *, /, %, ++, --
  • Relational operators : ==, !=, >, <, >=, <=
  • Bitwise operators : &, |, ^(xor), ~
    ex) 60 & 13 = 0011_1100 & 0000_1101 = 0000_1100 = 12
    ex) 60 | 13 = 0011_1100 | 0000_1101 = 0011_1101 = 61
    ex) 60 ^ 13 = 0011_1100 ^ 0000_1101 = 0011_0001 = 49
    ex) ~60 = 1100_0011 = 2의 보수 ... -61 (~하고 +1)
    ex) A << 2 = 240 (60x2x2) = 1111_0000 (0으로 채우면서 감)
    ex) A >> 2 = 15 (60/2/2) = 1111
    ex) a >>> 2 = 15 = 0000_1111 (0으로 채우면서 감)
  • Logical operators : &&, ||, !
  • Assignment operators : =, +=, -=, *=, /=

Control flow / Loop / Branching

  • if / else if / else
  • for / while / do while
for (int i = 0; i < ~~.length; i++) {
	System.out.println(~~);
}
    
while (i < ~) {
	System.out.println(~~);
}

do {
	System.out.println(~~);
} while (i < ~)
  • break, continue, return

Java output / constant

  • System.out.println();
  • System.out.print();
  • final

Overriding vs Hiding

  • Overriding
    Subclass에서 superclass와 같은 signature를 가진 new instance method를 선언한 것.

  • Hiding
    Subclass에서 superclass와 같은 signature를 가진 new static method를 선언한 것.

0개의 댓글