목록분류 전체보기 (123)
남극
Iterator Iterator에는 제네릭스가 적용되어 있습니다. public interface Iterator{ boolean hasNext(); E next(); void remove; } 이것이 실제로 구현되어 있는 소스코드입니다. 보면 감이 오실 수도 있습니다. 리스트를 반복할 때 사용되는 인터페이스입니다. ArrayList list = new ArrayList(); list.add("a"); list.add("b"); list.add("c"); 이렇게 리스트에 값을 추가했다고 가정했을 때, 이때의 iterator는 어떻게 사용하는지 알아봅시다. Iterator it = list.iterator(); 선언을 했습니다. while(it.hasNext()){ String t = it.next(); S..

import java.util.Scanner; public class Baekjoon1085 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); int w = sc.nextInt(); int h = sc.nextInt(); System.out.println(Math.min(Math.min(w - x, x), Math.min(h - y, y))); } }

import java.util.HashMap; import java.util.Scanner; public class Baekjoon1076 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String f = sc.next(); String s = sc.next(); String t = sc.next(); sc.close(); Long result; HashMap map = new HashMap(); map.put("black", "0,1"); map.put("brown", "1,10"); map.put("red", "2,100"); map.put("orange", "3,1000"); map.put("yellow..

public class Baekjoon4673 { public static void main(String[] args) { boolean[] snum = new boolean[10001]; for (int i = 1; i < 10000; ++i) { int result = toSnum(i); if (result 0) { result += a % 10; a /= 10; } return result; } }

Math 클래스 Math 클래스는 우리가 수학을 계산할 때 좋은 메서드들을 가지고 있습니다. 사실 이건 알아두면 유용하다고 생각하여 공부하는 김에 올려보려고 합니다. 우선 Math 클래스에서 가지고 있는 메서드들입니다. 자주 쓰이는 것 3개를 알아보도록 하겠습니다. Random Random a = new Random(); for (int i = 0; i < 10; i++) { System.out.println(a.nextInt(100)); } 45 27 30 69 73 54 58 67 50 1 포문을 사용해서 랜덤 함수를 10번 호출했습니다. 1~100 사이의 값 중에서 무작위로 출력하였습니다. 기본적으로 int를 사용하고 boolean 등 여러 가지 타입으로 반환받을 수 있습니다. Round Syste..