07 자바의 다양한 클래스.key

Similar documents
PowerPoint Presentation

PowerPoint 프레젠테이션

02 C h a p t e r Java

ilist.add(new Integer(1))과 같이 사용하지 않고 ilist.add(1)과 같이 사용한 것은 자바 5.0에 추가된 기본 자료형과 해당 객체 자료 형과의 오토박싱/언박싱 기능을 사용한 것으로 오토박싱이란 자바 컴파일러가 객체를 요구하는 곳에 기본 자료형

11 템플릿적용 - Java Program Performance Tuning (김명호기술이사)

Microsoft PowerPoint - Introduction to Google Guava.pptx

PowerPoint 프레젠테이션

PowerPoint Presentation

gnu-lee-oop-kor-lec11-1-chap15

비긴쿡-자바 00앞부속

12-file.key

슬라이드 1

항상쌍 ( 키, 값 ) 으로만데이터를저장하는클래스 의최고조상 : Map - Map을조상으로하는클래스, HashTable, HashMap, LinkedHashMap, TreeMap 등은데이터를저장할때반드시 키 와 값 의쌍으로저장한다. - Map에저장되는 키 는중복되면안되

09-interface.key

6장.key

untitled

1

C# Programming Guide - Types

05-class.key

Microsoft PowerPoint - Lect07.pptx

PowerPoint 프레젠테이션

rmi_박준용_final.PDF

자바 프로그래밍

PowerPoint 프레젠테이션

Java

PowerPoint Presentation

K&R2 Reference Manual 번역본

PowerPoint Presentation

JMF3_심빈구.PDF

쉽게 풀어쓴 C 프로그래밍

목차 INDEX JSON? - JSON 개요 - JSONObject - JSONArray 서울시공공데이터 API 살펴보기 - 요청인자살펴보기 - Result Code - 출력값 HttpClient - HttpHelper 클래스작성 - JSONParser 클래스작성 공공

@OneToOne(cascade = = "addr_id") private Addr addr; public Emp(String ename, Addr addr) { this.ename = ename; this.a

초보자를 위한 자바 2 21일 완성 - 최신개정판

Java XPath API (한글)

5장.key

90 Java의정석定石 3판 - 연습문제풀이 Chapter 컬렉션프레임웍 Collections Framework

Interstage5 SOAP서비스 설정 가이드

PowerPoint Presentation

03-JAVA Syntax(2).PDF

ch09

PowerPoint 프레젠테이션

Java ~ Java program: main() class class» public static void main(string args[])» First.java (main class ) /* The first simple program */ public class

Spring Boot/JDBC JdbcTemplate/CRUD 예제

PowerPoint 프레젠테이션

프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어

fundamentalOfCommandPattern_calmglow_pattern_jstorm_1.0_f…

자바-11장N'1-502

PowerPoint 프레젠테이션

Connection 8 22 UniSQLConnection / / 9 3 UniSQL OID SET

Microsoft PowerPoint - Java7.pptx

Microsoft PowerPoint - 04-UDP Programming.ppt

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

Microsoft Word - java18-1-final-answer.doc

01-OOPConcepts(2).PDF

자바GUI실전프로그래밍2_장대원.PDF

쉽게 풀어쓴 C 프로그래밍

Design Issues

Microsoft PowerPoint - 2강

Microsoft PowerPoint - java2-lecture4.ppt [호환 모드]

JAVA PROGRAMMING 실습 02. 표준 입출력

MasoJava4_Dongbin.PDF

슬라이드 1

Microsoft PowerPoint - java2-lecture5.ppt [호환 모드]

교육자료

(Microsoft PowerPoint - java1-lecture9.ppt [\310\243\310\257 \270\360\265\345])

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx

Microsoft PowerPoint 자바-기본문법(Ch2).pptx

Microsoft PowerPoint - java1-lecture7.ppt [호환 모드]

<4D F736F F F696E74202D205B4A415641C7C1B7CEB1D7B7A1B9D65D36C0E5C6D0C5B0C1F6>

[ 정보 ] 과학고 R&E 결과보고서 Monte Carlo Method 를이용한 고교배정시뮬레이션 연구기간 : ~ 연구책임자 : 강대욱 ( 전남대전자컴퓨터공학부 ) 지도교사 : 최미경 ( 전남과학고정보 컴퓨터과 ) 참여학생 : 박진명 ( 전

슬라이드 1

Microsoft PowerPoint - lec7_package [호환 모드]

FileMaker ODBC and JDBC Guide

12-file.key

Spring Data JPA Many To Many 양방향 관계 예제

FileMaker ODBC and JDBC Guide

Microsoft PowerPoint - java2-lecture3.ppt [호환 모드]

슬라이드 1

Mobile Service > IAP > Android SDK [ ] IAP SDK TOAST SDK. IAP SDK. Android Studio IDE Android SDK Version (API Level 10). Name Reference V

Java ...

(8) getpi() 함수는정적함수이므로 main() 에서호출할수있다. (9) class Circle private double radius; static final double PI= ; // PI 이름으로 로초기화된정적상수 public

PowerPoint Presentation


PowerPoint 프레젠테이션

chap10.PDF

PowerPoint 프레젠테이션

Analytics > Log & Crash Search > Unity ios SDK [Deprecated] Log & Crash Unity ios SDK. TOAST SDK. Log & Crash Unity SDK Log & Crash Search. Log & Cras

쉽게 풀어쓴 C 프로그래밍

A Tour of Java IV

Microsoft PowerPoint - Lect04.pptx

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf("hihi\n"); } warning: conflicting types for functiona

JMF2_심빈구.PDF

Microsoft PowerPoint - java1-lecture8.ppt [호환 모드]

Microsoft PowerPoint - java1-lecture8.ppt [호환 모드]

Microsoft PowerPoint - java1-lecture8.ppt [호환 모드]

초보자를 위한 C# 21일 완성

쉽게 풀어쓴 C 프로그래밍

* Factory class for query and DML clause creation * tiwe * */ public class JPAQueryFactory implements JPQLQueryFactory private f

A Tour of Java V

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각

Transcription:

[ 07 ]

. java.lang Object, Math, String, StringBuffer Byte, Short, Integer, Long, Float, Double, Boolean, Character. java.util Random, StringTokenizer Calendar, GregorianCalendar, Date. Collection, List, Queue, Set, Map LinkedList, Vector, HashSet, HashMap 2

1. JAVA.LANG 3

Section 1 java.lang p256 API (java class library) API http://docs.oracle.com/javase/7/docs/api 4

Section 1 java.lang java. javax. org. com. 5

Section 1 java.lang java.lang java.lang Object, Integer, String, StringBuffer, Math import 6

Object Section 1 java.lang Object Object tostring() (overriding) " @16 " equals() 7

Math Section 1 java.lang 8

Object Math 7-1 Section 1 java.lang 9

8 (wrapper class) Section 1 java.lang 10

Section 1 java.lang Integer Integer Integer age = new Integer(20); Integer snum = new Integer("20121105"); int int intvalue() 11

Section 1 java.lang Jdk 1.5 Double 2.59 Double radius = new Double(2.59); Jdk 1.5 (boxing) Double radius = 2.59; //boxing double r double r = radius.doublevalue(); (unboxing) double r = radius; //unboxing 12

Character Section 1 java.lang 7-4 13

Section 1 java.lang String(1) String 14

String(2) Section 1 java.lang 15

String(3) Section 1 java.lang 7-5 16

StringBuffer(1) Section 1 java.lang (capacity) StringBuffer StringBuffer sb1 = new StringBuffer(); // 16 StringBuffer sb2 = new StringBuffer(32); // 32 StringBuffer sb3 = new StringBuffer("java"); 17

StringBuffer(2) Section 1 java.lang, StringBuffer 18

StringBuffer(3) Section 1 java.lang 7-6 19

2. JAVA.UTIL 20

java.util Section 2 java.util p268 Calendar, GregorianCalendar, Date Random (random number) Vector, Stack Collection, Set, List, Queue, Map 21

Section 2 java.util Random int, long, float, double long Random rnd1 = new Random(); Random rnd2 = new Random(45); 22

Section 2 java.util 7-7 23

StringTokenizer(1) (token) (delimiters) " \t\n\r\f" \t 4 StringTokenizer 2 Section 2 java.util StringTokenizer 3 true String str = "public static void main(string[] args) {"; StringTokenizer st1 = new StringTokenizer(str); StringTokenizer st2 = new StringTokenizer(str, " ()"); StringTokenizer st3 = new StringTokenizer(str, " ()[] {"); StringTokenizer st4 = new StringTokenizer(str, "()[]{", true); 24

StringTokenizer(2) StringTokenizer Section 2 java.util 25

Section 2 java.util 7-8 26

Section 2 java.util Date Date deprecated Date Calendar, 1/1000 millisecond gettime() 1970 1 1 00:00:00 millisecond 1970 1 1 00:00:00 epoch DateFormat java.text Locale Date now = new Date(); System.out.println(now); System.out.println(now.getTime()); java.util 27

Section 2 java.util 7-9 28

Section 2 java.util Calendar getinstance() gettime() Date, Calendar now = Calendar.getInstance(); System.out.println(now.getTime()); 29

Calendar Section 2 java.util 7-10 import java.util.calendar; public class CalendarTest { public static void main(string[] args) { Calendar now = Calendar.getInstance(); System.out.println(now.getTime()); " "); } } int year = now.get(calendar.year); int month = now.get(calendar.month) + 1; // 0 int date = now.get(calendar.date); int hour = now.get(calendar.hour_of_day); int minute = now.get(calendar.minute); int second = now.get(calendar.second); System.out.println(year + " " + month + " " + date + " "); System.out.println(hour + " " + minute + " " + second + 30

3. 31

Section 3 p276 collection framework Collection, Set, List, Queue, Map 32

Section 3 Collection Collection Map Collection Set List Queue Set List Queue Map (key) (value) 33

Section 3 HashMap [ ][ ] HashMap Hash Map 34

Section 3 Collection Collection, List, Set, Queue 35

Iterator Section 3 iterator() Iterator Collection c iterator() Iterator hasnext() next() Iterator it = c.iterator(); while ( it.hasnext() ) { } System.out.println(it.next()); 36

Section 3 List List LinkedList, ArrayList, Vector, Stack 37

ListIterator Section 3 Iterator 38

LinkedList List Queue null addfirst() : add() addlsat() : add(index) Section 3 39

LinkedList Section 3 40

Section 3 7-12 41

Section 3 Vector(1) capacity 2 Vector<Object> Object Vector<Object> data = new Vector<Object>(); data.addelement(2012); data.add(" "); 42

Vector(2) Section 3 43

Section 3 7-13 import java.util.vector; public class VectorTest { public static void main(string[] args) { Vector<Object> data = new Vector<Object>(3); //Vector data = new Vector(3); // data.addelement(2012); data.add(" "); data.addelement(4.35); data.add(2, " "); data.insertelementat(" ", 0); System.out.println("size = " + data.size()); System.out.println("capacity = " + data.capacity()); System.out.println(data.toString()); } } 44

Section 3 Set Collection Set TreeSet Set SortedSet Set HashSet (hash table) Set Collection Collection 45

Section 3 7-14: HashSet Set 7 HashSet Integer HashSet<Integer> public class void HashSetTest { HashSet<Integer> seta = new HashSet<Integer>(); HashSet<Integer> setb = new HashSet<Integer>(); seta.add(3); seta.add(5); seta.add(7); seta.add(8); seta.add(7); seta.add(9); System.out.print("A = "); print(seta); System.out.println(" A = " + seta); setb.add(5); setb.add(3); setb.add(2); System.out.print("B = "); print(setb); System.out.println(" B = " + setb); boolean ischanged = seta.removeall(setb); System.out.print("A - B = "); if (ischanged) System.out.println(setA);; } } public static void print(hashset<integer> s) { Iterator<Integer> i = s.iterator(); while ( i.hasnext() ) System.out.print(i.next()+ " "); } 46

Section 3 Map (1) (key) (value) put(key, value) get(key) HashMap, TreeMap HashMap Map 47

Map (2) Section 3 48

HashMap Section 3 Map null 7-15 import java.util.hashmap; import java.util.iterator; public class HashMapTest { public static void main(string[] args) { HashMap<String, String> hm = new HashMap<String, String>(); hm.put(" ", " "); hm.put(" ", " "); hm.put(" ", " "); hm.put(" ", " "); hm.remove(" "); hm.put(" ", " "); System.out.print(" : " + hm.keyset()); System.out.println(" : " + hm.values()); } Iterator<String> keys = hm.keyset().iterator(); while ( keys.hasnext() ) { String key = keys.next(); String value = hm.get(key); System.out.println(key + ": " + value); } 49

4. 50

Section 4 p288 Generic (generic type) HashMap<String, String> Map String String <Object, Object> 51

Section 4 Generic MyContainer<E> E MyContainer (element) MyContainer<E> MyContainer<String> pl pl.add( algol ) MyContainer<Object> 52

Section 4 7-16 package generics; import java.util.arraylist; public class MyContainer<E> { private ArrayList<E> list; public MyContainer() { list = new ArrayList<E>(); } public E get(int index) { return list.get(index); } public void add(e element) { list.add(element); } 07 } public static void main(string[] args) { MyContainer<String> pl = new MyContainer<String>(); pl.add("algol"); pl.add("c"); //pl.add(5); pl.add("java"); System.out.println(pl.get(0) + " "); System.out.println(pl.get(1) + " "); System.out.println(pl.get(2) + " "); } 53

Generic Section 4 get() <T> static <T> T <T> ary T[] 7-17 package generics; public class MyGenerics { public static <T> T get(t[] ary, int index) { return ary[index]; } public static <T> T getlast(t[] ary) { return ary[ary.length-1]; } public static void main(string[] args) { Integer n[] = {3, 4, 5, 7}; System.out.println(MyGenerics.get(n, 2) + " " + MyGenerics.getLast(n)); String s[] = {"generics", "type casting", "input", "output"}; System.out.println(MyGenerics.get(s, 1) + " " + MyGenerics.getLast(s)); } } 07 54

Section 4 (enumeration data type), enum pl c, cpp, java, csharp values() switch case public class EnumTest { public enum pl {c, cpp, java, csharp}; public static void main(string[] args) { pl clang = pl.c; // System.out.println(clang); // clang = pl.csharp; switch(clang) { case csharp: System.out.println(clang + ": C# "); } } } for (pl p : pl.values()) System.out.print(p + " "); System.out.println(); 55

56

[ Add your company slogan ] Thank You!