본문 바로가기

반응형

콩's EDUCATION/콩's JAVA_RUN

(105)
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 = ..

반응형

⚠️ 광고 차단 프로그램 감지

애드블록, 유니콘 등 광고 차단 확장 프로그램을 해제하거나
화이트리스트에 추가해주세요.