본문 바로가기

콩's EDUCATION/콩's JAVA_RUN

스레드(Thread) Thread 예제 class SimpleThread extends Thread{ String msg; public SimpleThread(String msg) { this.msg = msg; } public void run(){ for(int i=1;i 더보기
Java 문제 7 CompareUtil 클래스의 void compareList (ArrayList first, ArrayList second) 메소드를 완성하십시오. compareList 메소드는 ArrayList 타입의 객체 2개를 입력받아 저장 데이터를 하나씩 비교하고 차이가 있는 경우에만 HashMap에 저장하여 리턴합니다. class CompareUtilMain { main 적절히 구현 } > No 첫번째 ArrayList 내용 두번째 ArrayList 내용 결과값(HashMap) 1 Learn to build powerful Enterprise Java applications using the Spring Framework. Learn To Build Powerful Enterprise Java applicati.. 더보기
Java 문제 6 1. class OverridingTest { public static void main(String args[]){ int i = 10; int j = 20; MySum ms1 = new MySum(i, j); MySum ms2 = new MySum(i, j); System.out.println(ms1); if(ms1.equals(ms2)) System.out.println ("ms1과 ms2의 합계는 동일합니다."); } } class MySum { int first; int second; MySum (int first, int second){ this.first = first; this.second = second; } /* 조건1 */ /* 조건2 */ } 조건1: main 메소드에서 MySum .. 더보기
SimpleDateFormat SimpleDateFormat 예제 import java.text.SimpleDateFormat; import java.util.Calendar; public class CalendarTest { public static void main(String[] args) { Calendar now = Calendar.getInstance(); // 년도-월-일-시-분-초 int year = now.get(Calendar.YEAR); // 5월값 저장변수 january = 0, May = 4 이다. int month = now.get(Calendar.MONTH)+1; int day = now.get(Calendar.DAY_OF_MONTH); int hour = now.get(Calendar.HOUR_OF_DAY.. 더보기
Calendar Calendar 시간 표시하기 import java.util.Calendar; public class CalendarTest { public static void main(String[] args) { Calendar now = Calendar.getInstance(); // 년도-월-일-시-분-초 int year = now.get(Calendar.YEAR); // 5월값 저장변수 january = 0, May = 4 이다. int month = now.get(Calendar.MONTH)+1; int day = now.get(Calendar.DAY_OF_MONTH); int hour = now.get(Calendar.HOUR_OF_DAY); int min = now.get(Calendar.MINUTE);.. 더보기
Date DATA 예제 import java.util.*; // JDK 생성자나 메소드 사용 자제 deprecated(한줄 그어진 것) 경고 // JDK 업그레이드 되면서 대체 기능 다른 클래스 포함 // Date 삭제 ; 이미 Date를 사용중인 프로그램 위해 남겨졌다. public class DateTest { public static void main(String[] args) { Date d = new Date(); System.out.println(d); System.out.println(d.toGMTString()); // 영문권 System.out.println(d.toLocaleString()); // 한국 } } Tue May 20 15:04:05 KST 2014 20 May 2014 06:04:.. 더보기
HashMap HashMap import java.util.HashMap; import java.util.Iterator; public class HashMapTest { public static void main(String[] args) { HashMap phones = new HashMap(); // 강감찬 : 배열 {핸드폰, 집, 사무실} String phone1[] ={"010-1111-2222","02-3456-7890","031-1234-5678"}; String phone2[] ={"010-3333-4444","02-3456-7890"}; String phone3[] ={"010-5555-6666"}; String phone4[] ={"010-7777-8888"}; phones.put("강감찬", pho.. 더보기
Stack 과 Queue Stack 과 Queue 예제 import java.util.LinkedList; import java.util.Queue; public class StackTest { public static void main(String[] args) { Stack s = new Stack(); s.push("a"); s.push("b"); s.push("c"); s.push("d"); // 현재 상태 ; d ; 꼭대기 데이터 접근 조회 if(!s.empty()){ System.out.println("가장 위 ="+s.peek()); s.pop(); // 현재 꼭대기 데이터 삭제 ; d System.out.println("가장 위 ="+s.peek()); s.pop(); // 현재 꼭대기 데이터 삭제 ; c Syst.. 더보기
Vector 저장데이터, 총크기, 데이터 조회 2 2014/05/20 - [콩's EDUCATION/콩's JAVA_RUN] - Vector 저장데이터, 총크기, 데이터 조회 Vector 저장데이터, 총크기, 데이터 조회 2 import java.util.*; class Employee /*extends Object*/{ int id; // 사번 String name; // 이름 double pay; // 급여 // 멤버 변수를 초기화해주는 것이 생성자(기본 개념 숙지) public Employee(int id, String name, double pay) { this.id = id; this.name = name; this.pay = pay; } @Override public String toString() { return "Employee [id=".. 더보기
HashSet 저장데이터, 데이터 조회 HashSet 저장데이터, 데이터 조회 import java.util.*; public class HashSetTest { public static void main(String[] args) { /** * HashSet 생성 * 100(interger), 3.14(Double), "java" */ HashSet all = new HashSet(); // 5+5+5+..... all.add(100); all.add(3.14); all.add("java"); Employee e1 = new Employee(100, "홍길동", 67000.99); all.add(e1); Employee e2 = new Employee(200, "강감찬", 31000.14); all.add(e2); Employee e3 = .. 더보기