분류 전체보기(145)
-
Day 19(8/26) 좌석 예약 시스템
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 public class CinemaReserve { public static void main(String[] args) { String[][] seat = new String[4][8]; String[] list = { "A", "B", "C", "D" }; for (int i = 0; i
2016.08.29 -
Day 18(8/25) 숫자 맞추기 게임, 가위바위보
**오늘 배운 내용** 1) 숫자 맞추기 게임 2) 가위바위보 게임 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 //숫자 맞추기 게임 public class L01Su { public static void main(String[] args) { int random = (new Random().nextInt(20)); Scanner scan = new Scanner(System.in); System.out.println("1~20 중 숫자 하나 입력해주세요."); int you = 0; int count = 6; while (you != random) { count--; if(count==0){ System.out.println..
2016.08.26 -
Day 17(8/24) Try~Catch, throws
**오늘 배운 내용**1) Try ~ Catch 활용2) Reader, Buffer 개념3) throws 활용 1234567891011121314151617181920212223242526272829303132333435363738import java.util.Scanner;public class L01TryCatch { public static void main(String[] args) { int[] c = {0,1,2,3}; int i = 3; int j = 1; if(i=0){ if(c[j]!=0){ System.out.println(c[i]/c[j]); } }else{ System.out.println("오류가 발생해서 예외처리했습니다."); } try{ System.out.println("tr..
2016.08.26 -
Day 16(8/22) ArrayList, HashMap, HashSet
**오늘 배운 내용** 1) ArrayList 인자 추가 및 출력 2) HashMap 저장 및 출력 3) HashSet은 중복 저장 불가(put도) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 import java.util.ArrayList;//제네릭을 가진다. import java.util.List;//ArrayList를 구현하기 위한 interface(설계도) public class L01ArrayList { public static void main(String[] args) { List list = new ArrayList();//아무것도 쓰지 않으면 generic은 Object l..
2016.08.23 -
Day 15(8/19) Generic
**오늘 배운 내용**1) 객체 생성시 데이터타입 맞추기2) Generic 활용 12345678910111213141516171819202122class Animal{ Object name; int int_name; public Animal(Object name){ this.name = name; } public Animal(int int_name){ this.int_name = int_name; }} //해결법 //1. 필드추가 + 생성자 오버로드 => 필드와 생성자가 계속 추가되면 코드가 길어지고 유지보수가 힘듬. //2. name dataType 변경(모든 클래스의 조상인 Object를 데이터타입으로) -> 코드가 짧아지고 flexible해짐 //3. 제네릭 -> 2번 방식 고수하다 심각한 오류 때..
2016.08.23 -
Day 14(8/18) Final, Enum
**오늘 배운 내용**1. Final 상수화2. Enum 12345678910111213141516171819202122232425262728293031323334class FRUIT2{ public static final FRUIT2 APPLE = new FRUIT2("사과"); //자기 자신의 객체를 생성해 저장한다. public static final FRUIT2 PEACH = new FRUIT2("복숭아"); public static final FRUIT2 BANANA = new FRUIT2("바나나"); String msg; private FRUIT2(String msg){ this.msg = msg; }}//class end class COMPANY2{ public static final CO..
2016.08.23