Calendar package kr.s21.object.util; import java.util.Calendar; public class CalendarMain01 { public static void main(String[] args) { Calendar today = Calendar.getInstance(); System.out.println(today); //연도 int year = today.get(Calendar.YEAR);//(스태틱한 상수) //월 int month = today.get(Calendar.MONTH)+1;//월을 반환할 때 1~12가 아닌 0~11을 반환하기 때문에 마지막에 +1을 해줘야지 올바른 월이 나온다. //괄호 안에 +1을 하면 다른 값이 나옴 //일 int date ..
쌍용교육(JAVA)
package kr.s20.object.lang; public class WrapperMain01 { public static void main(String[] args) { boolean b = true; //기본 자료형 데이터 Boolean wrap_b = new Boolean(b);//기본 자료형 데이터 -> 참조 자료형 데이터 //참조 자료형 데이터 -> 기본 자료형 데이터 boolean b2 = wrap_b.booleanValue(); System.out.println(b2); System.out.println("------------------");//위에는 예전에 했던 방식 char c = 'A'; //기본 자료형 Character wrap_c = c;//기본자료형 데이터 -> 참조자료형 데..
package kr.s20.object.lang; public class MathMain { public static void main(String[] args) { //절대값 처리 int a = Math.abs(-10); System.out.println("절대값:"+ a); //소수첨 올림처리 double b = Math.ceil(3.3); System.out.println("올림처리"+b); //소수점 버림처리 double c = Math.floor(3.7); System.out.println("버림"+c); //반올림 처리 round() 괄호안에는 무조건 floor 만 가능 double 안됨 int d = Math.round(3.7f); System.out.println("반올림:"+d); //2..
package kr.s20.object.lang; public class SpringBufferMain { public static void main(String[] args) { StringBuffer sb = new StringBuffer("여름 덥다!!"); System.out.println("1:" + sb); //지정한 인덱스이 문자 삽입 sb.insert(2, "이"); //2번 인덱스에 "이"라는 값을 새롭게 삽입한다. System.out.println("2:" + sb); //문자열 뒤에 새로운 문자열을 추가 sb.append("가을은"); System.out.println("3:" + sb); sb.append("시원하다"); System.out.println("4:" + sb); //시..
package kr.s20.object.lang; /* * 문자열 - 명시적으로 객체 * String s = new String("하늘); * String s3 = new String("하늘); *메모리 안에 하늘이라는 객체가 각자 생성된다.(2개의 하늘 객체가 메모리에 들어감) * * 문자열 - 암시적으로 객체 * String s2 = "바다"; * String s4 = "바다"; * 메모리 안에는 바다라는 한 개의 객체를 s2와 s4가 서로 공유한다.(바다 라는 객체 1개만 존재) */ public class SpringMain01 { public static void main(String[] args) { //암시적으로 문자열 생성 //같은 문자열을 사용할 경우 객체를 공유 String str1 =..
package kr.s20.object.lang; public class ObjectMain01 { public static void main(String[] args) { ObjectMain01 ob = new ObjectMain01(); System.out.println(ob.getClass()); System.out.println(ob.getClass().getName());//클래스명 반환 System.out.println(ob.hashCode());//10진수의 유니크한 값 반환(object의 해시코드 값을 반환해주는 코드) //10진수 -> 16진수(로 변환) System.out.println(Integer.toHexString(ob.hashCode())); System.out.println(..