본문 바로가기

전체 글251

Sort 1. 배열 : Arrays.sort()2. Collections.sort()-List-Set : List로 변환 뒤 sort-Map : Set -> List 로 변환 뒤 sort(entrySet() 사용) 3. Comparable 인터페이스 : 정렬하고자 하는 객체 내에서 Comparable 구현compareTo() 재정의. 한 가지의 정렬방법만 기본 제공 4. Comparator 인터페이스 : 기본 정렬 방법 이외 sort 알고리즘을 적용하고자 할 때 사용.구현된 객체를 Arrays.sort(), Collections.sort()에 정렬 대상 객체와 함께 인자로 넘겨준다. 2018. 2. 20.
이름 나이 오름차순 내림차순 2018. 2. 20.
배열 정렬 package education.sort; import java.util.Arrays; public class SortEx1 { public static void main(String[] args) { int[] num = {3,7,4,9,2,6,5,8,1};for(int i=0; i 2018. 2. 20.
Oracle SQL 마당 SQL select * from book; // * 모든 book 출력select * from customer; // * 모든 customer 출력select * from orders; // * 모든 orders 출력select * from imported_book; // * 모든 imported_book 출력select bookid, bookname from book where price >= 10000; // 10000원 이상 ~~ 출력select bookid, bookname from book where bookname like '%축구%' and price 2018. 2. 12.
JAVA 자바 빵 예제 (ver.강사님) import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; import java.util.Iterator; import java.util.Scanner; import java.util.StringTokenizer; public class Bakery2 { static int sum =0;// 주문수량 static ArrayList breadType = new ArrayList(); // 빵종류 static HashMap hashmap = new HashMap(); static HashMap hashmap2 = new HashMap(); public static void main(String[] args) { // 1. .. 2018. 2. 10.
JAVA 자바 빵/4개/생산날짜/유통기한/n개 import java.util.ArrayList; import java.util.Calendar; import java.util.Scanner; public class Input_3 { @SuppressWarnings("resource") public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("빵의 개수를 입력하세요 : "); int num = sc.nextInt(); System.out.println("만들 빵의 갯수는 "+num+"입니다."); System.out.println("빵의 이름을 입력하세요 :"); ArrayList bread = new ArrayList(); Scanner.. 2018. 2. 9.
JAVA 자바 HashMap ("지역번호","지역") package edu.collection; import java.util.HashMap; public class CollectionEx4 { public static void main(String[] args) { HashMap tel = new HashMap(); tel.put("052", "울산"); tel.put("051", "부산"); tel.put("02", "서울"); tel.put("052", "울산2"); // HashMap의 경우, 나중에 온 값이 덮어씌워 짐. System.out.println(tel.get("051")); System.out.println(tel.get("052")); System.out.println(tel.get("02")); } } 2018. 2. 9.
[JAVA] 자바 부분집합, 교집합, 합집합, 차집합 package edu.collection; import java.util.HashSet; import java.util.Iterator; public class CollectionEx3 { public static void main(String[] args) { HashSet hs1 = new HashSet(); hs1.add("a"); hs1.add("b"); hs1.add("c"); HashSet hs2 = new HashSet(); hs2.add("c"); hs2.add("d"); hs2.add("e"); HashSet hs3 = new HashSet(); hs3.add("a"); hs3.add("b"); // Case_1 부분집합 System.out.println("부분집합"); System.ou.. 2018. 2. 8.
JAVA 자바 List, Set 차이 package edu.collection; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; public class CollectionEx2 { public static void main(String[] args) { ArrayList al = new ArrayList(); //순차적 al.add("first"); al.add("second"); al.add("third"); al.add("third"); al.remove("third"); al.add("forth"); System.out.println("--ArrayList--"); System.out.println(al); //Iterator 객체를 통해 .. 2018. 2. 8.