목록[JAVA]/10. API (13)
Beny's Study
class Parsing package com.kh.ex02.string_usage; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; //https://www.kobis.or.kr/kobisopenapi/homepg/apiservice/searchServiceInfo.do //http://kobis.or.kr/kobisopenapi/webservice/rest/boxoffice/searchWeeklyBoxOfficeList.json?key=f5eef3421c602c6cb7ea224104795888&targetDt=20120101 pu..
String 사용 tip 1. String 의 저장소는 Heap과 String constant pool두가지가 있다. 2. String constant pool을 사용하는 것이 메모리 관리측면세어 유리하다. 3. String 은 new 생성하지 않는다, 4.Haep을 생으로 생성하지 않는다. *String pool이란? String존재하는 수영장(영역)! String constant pool String str1 = "Test String"; // 제일 표준 문법,String constant pool String str2 = new String("Test String"); // 스캐너 사용같은 경우, Heap String str3 = str1.toString(); // str1에 toString 찍어서 ..
SimpleDateFormat 클래스 ■ Date의 날짜, 시간 정보를 원하는 format으로 출력하는 기능 제공 java.text 패키지에 속해있음 ■ 예시 Date today = new Date(); SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd"); String ftToday = ft.format(today); //today에 포맷을 적용한 결과를 문자열로 리턴 Formatter 클래스 ■ 값 출력 시 format 적용하여 출력 ■ Formatter 객체 생성 시 변환된 결과를 보낼 곳의 정보를 생성자 인자로 전달 ■ 예시 Formatter f = new Formatter(System.out); f.format("%s, %d, %d \n", "St..
Date 클래스 ■ 시스템으로부터 현재 날짜, 시간 정보를 가져와서 다룰 수 있게 만들어진 클래스 ■ 생성자 2개만 사용 가능하고 나머지는 모두 deprecated ■ Calendar 클래스 혹은 GregorianCalendar 클래스 사용 권장 [예시] Date today = new Date(); // 시스템으로부터 현재 날짜, 시간 정보를 가져와 기본 값으로 사용 Date when = new Date(123456798L); // long형 정수 값을 가지고 날짜 시간 계산 // 1970년 1월 1일 0시 0분 0초를 기준으로 함 Calendar 클래스 ■ Calendar클래스는 생성자가 protected이기 때문에 new연산자를 통해 객체 생성 불가능 ■ getInstance() 메소드를 통해서 객체..
Wrapper 클래스 Primitive Data Type을 객체화 해주는 클래스 String을 기본 자료형으로 바꾸기 byte b = Byte.parseByte("1"); short s = Short.parseShort("2"); int i = Integer.parseInt("3"); long l = Long.parseLong("4"); float f = Float.parseFloat("0.1"); double d = Double.parseDouble("0.2"); boolean bool = Boolean.parseBoolean("true"); char c = "abc".charAt(0); 기본 자료형을 String으로 바꾸기 String b = Byte.valueOf((byte)1).toString()..