그림에서 확인할 수 있듯이 SLF4J에서 제공하는 3가지 모듈을 통해 수행될 수 있다.
pom.xml에 dependency를 추가해주면 log4j, slf4j 둘다 사용이 가능하다
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j-slf4j-impl.version}</version>
</dependency>
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class slf4jTest {
private static Logger logger = LoggerFactory.getLogger(slf4jTest.class);
public static void main(String[] args) {
for (int count = 1; count <= 5; count++) {
logger.info("slf4j TEST", count);
}
}
}
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class slf4jTest {
private static Logger logger = LogManager.getLogger(slf4jTest.class);
public static void main(String[] args) {
for (int count = 1; count <= 5; count++) {
logger.info("log4j TEST", count);
}
}
}
둘다 같은 결과를 불러오지만
코드를 일정하게 유지하면서 구현체 전환으로 다른 로깅 프레임워크로 전환이 쉬운 SLF4J를 사용한다.
class Book {
private String title;
private String author;
public Book(String title, String author) {
this.title = title;
this.author = author;
}
@Override
public String toString() {
return title + "," + author;
}
}
public class BookTest {
public static void main(String[] args) {
Book book = new Book("데미안", "헤르만 헤세");
System.out.println(book.toString());
String str = new String("test");
System.out.println(str);
}
}
public class Student {
private int studentNum;
private String studentName;
public Student (int studentNum, String studentName) {
this.studentNum = studentNum;
this.studentName = studentName;
}
public String toString() {
return studentNum + "," + studentName;
}
@Override
public boolean equals(Object obj) {
if ( obj instanceof Student ) {
Student std = (Student)obj;
if (this.studentNum == std.studentNum)
return true;
else return false;
}
return false;
}
@Override
public int hashCode() {
return studentNum;
}
}
public class equalsTest {
public static void main(String[] args) {
Student std1 = new Student(100, "Lee");
Student std2 = new Student(100, "Lee");
// 논리적으로 다름
System.out.println(std1 == std2);
// 논리적으로 다르지만 같은 hash코드값이기 때문에 true 출력
System.out.println(std1.equals(std2));
System.out.println(std1.hashCode());
System.out.println(std2.hashCode());
// 실제 가진 주소
System.out.println(System.identityHashCode(std1));
System.out.println(System.identityHashCode(std2));
}
}
public class Student implements Cloneable{
.......
@Override
protected Object clone() throws CloneNotSupportedException {
// TODO Auto-generated method stub
return super.clone();
}
}
Student Lee3 = (Student)Lee.clone();
System.out.println(System.identityHashCode(Lee));
System.out.println(System.identityHashCode(Lee3));
String str1 = new String("abc");
String str2 = "abc";
public class StringTest {
public static void main(String[] args) {
String str1 = new String("abc");
String str2 = new String("abc");
System.out.println(str1 == str2); // false
String str3 = "abc";
String str4 = "abc";
System.out.println(str3 == str4); // true
}
}
public class StringTest2 {
public static void main(String[] args) {
String java = new String("java");
String android = new String("android");
java = java.concat(android);
System.out.println(java); // javaandroid
}
}
public class StringBuilderTest {
public static void main(String[] args) {
String java = new String("java");
String android = new String("android");
StringBuilder buffer = new StringBuilder(java);
System.out.println(System.identityHashCode(buffer)); //주소값 925858445
buffer.append(android);
System.out.println(System.identityHashCode(buffer)); //주소값 925858445
String test = buffer.toString();
System.out.println(test); // javaandroid
}
}
public class StringTextBlock {
public static void main(String[] args) {
String strBlock = """
This is
String
Block
""";
System.out.println(strBlock);
System.out.println(getBlockofHtml());
}
public static String getBlockofHtml() {
return """
<html>
<body>
<span>Test</span>
</body>
</html>
""";
}
}
1. charAt ( int index ) / char
char지정된 인덱스의 값을 반환합니다 .
public static void main(String[] args) {
final String str = "ABCD";
LOGGER.debug("charAt(0) = " + str.charAt(0));
}
2022-12-13 13:32:07.998 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(13) charAt(0) = A
2. codePointAt ( int index ) / int
지정된 인덱스에 있는 문자(유니코드 코드 포인트)를 반환합니다.
public static void main(String[] args) {
String str = "ABCD";
LOGGER.debug("codePointAt(0) = " + str.codePointAt(0));
}
2022-12-13 13:35:10.810 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(16) codePointAt(0) = 65
3. codePointBefore ( int index ) / int
지정된 인덱스 앞의 문자(유니코드 코드 포인트)를 반환합니다.
public static void main(String[] args) {
String str = "ABCD";
LOGGER.debug("codePointBefore(1) = " + str.codePointBefore(1));
}
2022-12-13 13:49:23.682 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(19) codePointBefore(1) = 65
4. codePointCount ( int beginIndex, int endIndex ) / int
지정된 텍스트 범위에 있는 유니코드 코드 포인트의 수를 반환
public static void main(String[] args) {
String str = "ABCD";
LOGGER.debug("(str.codePointCount(3, 4) = " + (str.codePointCount(3, 4)));
}
2022-12-13 13:48:31.713 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(22) (str.codePointCount(3, 4) = 1
5. compareTo ( String anotherString ) / int
두 문자열을 사전순으로 비교합니다. 값이 동일할 경우 0 출력
문자열의 길이가 다르면 차이만큼 반환, 같은 위치의 문자가 다르면 아스키 코드의 차이만큼 반환
public static void main(String[] args) {
String str = "ABCD";
LOOGGER.debug("str.compareTo('ABCD') = " + str.compareTo("ABCD"));
LOOGGER.debug("str.compareTo('A') = " + str.compareTo("A"));
LOOGGER.debug("str.compareTo('ABCB') = " + str.compareTo("ABCB"));
}
// 문자열이 같다
2022-12-13 14:00:33.086 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(25) str.compareTo('ABCD') = 0
// 문자열 길이 차이 반환
2022-12-13 14:00:33.088 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(26) str.compareTo('A') = 3
// D - B == 68 - 66
2022-12-13 14:00:33.089 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(27) str.compareTo('ABCB') = 2
6. compareToIgnoreCase( String str ) / int
대소문자 차이를 무시하고 두 문자열을 사전순으로 비교합니다.
public static void main(String[] args) {
String str = "ABCD";
LOGGER.debug("str.compareToIgnoreCase('abcd') = " + str.compareToIgnoreCase("abcd"));
LOGGER.debug("str.compareToIgnoreCase('aBcD') = " + str.compareToIgnoreCase("aBcD"));
}
2022-12-13 14:07:54.990 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(30) str.compareToIgnoreCase('abcd') = 0
2022-12-13 14:07:54.992 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(31) str.compareToIgnoreCase('aBcD') = 0
7. concat ( String str ) / String
문자열을 합쳐준다 초기 값이 null 이면 NullPointException 발생
public static void main(String[] args) {
String str = "ABCD";
String result = str.concat(" EFGH");
LOGGER.debug(result);
}
2022-12-13 14:10:19.268 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(35) ABCD EFGH
8. contains ( CharSequence s ) / boolean
이 문자열에 지정된 문자 값 시퀀스가 포함된 경우에만 true를 반환합니다.
public static void main(String[] args) {
String str = "가나다라";
String str2 = "가나";
String str3 = "나가다";
if (str.contains(str2)) {
LOGGER.debug("str에 str2가 포함돼있다.");
} else {
LOGGER.debug("str에 str2가 포함돼있지 않다.");
}
if (str.contains(str3)) {
LOGGER.debug("str에 str3가 포함돼있다.");
} else {
LOGGER.debug("str에 str3가 포함돼있지 않다.");
}
}
2022-12-13 14:21:30.543 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(41) str에 str2가 포함돼있다.
2022-12-13 14:21:30.545 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(48) str에 str3가 포함돼있지 않다.
9. contentEquals ( CharSequence cs ) / boolean
문자열에 특정 문자열이 정확히 일치하는지 확인해준다
public static void main(String[] args) {
String str = "가나다";
String str2 = "가나다";
String str3 = "가나";
if (str.contentEquals(str2)) {
LOGGER.debug("str에 str2가 포함돼있다");
} else {
LOGGER.debug("str에 str2가 포함되지않았다");
}
if (str.contentEquals(str3)) {
LOGGER.debug("str에 str3가 포함돼있다");
} else {
LOGGER.debug("str에 str3가 포함되지않았다");
}
}
2022-12-13 14:28:29.677 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(16) str에 str2가 포함돼있다
2022-12-13 14:28:29.680 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(23) str에 str3가 포함되지않았다
10. copyValueOf( char[] data ) / static String
char배열 값을 연결하여 문자열로 반환한다.
public static void main(String[] args) {
char[] c = { '가', '나', '다', '라', '마' };
String str = "";
LOGGER.debug(str.copyValueOf(c));
LOGGER.debug(str.copyValueOf(c, 0, 2));
}
2022-12-13 15:01:02.364 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(15) 가나다라마
2022-12-13 15:01:02.369 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(16) 가나
11. equals( Object anObject ) / boolean
다른 객체와 문자열을 비교하여 같으면 ture, 다르면 false 반환한다.
public static void main(String[] args) {
String str = "ABCD";
LOGGER.debug("str.equals('ABCD') = " + str.equals("ABCD"));
LOGGER.debug("str.equals('ABC') = " + str.equals("ABC"));
}
2022-12-13 15:07:16.752 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(13) str.equals('ABCD') = true
2022-12-13 15:07:16.754 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(14) str.equals('ABC') = false
12. equalsIgnorecase( String anotherString ) / boolean
문자열의 대소문자를 구분하지 않고 비교한다.
public static void main(String[] args) {
String str = "ABCD";
LOGGER.debug("str.equalsIgnoreCase('ABCD') = " + str.equalsIgnoreCase("ABCD"));
LOGGER.debug("str.equalsIgnoreCase('AbCd') = " + str.equalsIgnoreCase("AbCd"));
}
2022-12-13 15:09:05.190 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(13) str.equalsIgnoreCase('ABCD') = true
2022-12-13 15:09:05.192 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(14) str.equalsIgnoreCase('AbCd') = true
13. format(Locale l, Strng format, Objec args ..) / static String
서식 문자열을 사용하여 형식 문자열을 만들 수 있게 해준다.
public static void main(String[] args) {
String str = "String Sample";
boolean bool = true;
int i = 1234;
float n = 2.43043f;
LocalDateTime now = LocalDateTime.now();
String result = String.format("문자열 서식: %s, %S", str, str);
LOGGER.debug(result);
result = String.format("boolean 서식 문자열: %B, %b", bool, bool);
LOGGER.debug(result);
result = String.format("정수 서식: %d, %o, Dx, %05d", i, i, i, i);
LOGGER.debug(result); // %05d → 5자리수, 공백을 0으로 채움
result = String.format("float 서식: %.1f", n);
LOGGER.debug(result);
result = String.format("날짜/시간 서식: %tY년 %<tm월 %<td일 %<tH시 %<tM분 %<tS초", now);
LOGGER.debug(result); // $< 로 상대 인덱스 지정하여 직전의 인수와 같은 인덱스를 이용
}
2022-12-13 15:24:48.815 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(21) 문자열 서식: String Sample, STRING SAMPLE
2022-12-13 15:24:48.816 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(24) boolean 서식 문자열: TRUE, true
2022-12-13 15:24:48.822 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(27) 정수 서식: 1234, 2322, Dx, 01234
2022-12-13 15:24:48.824 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(30) float 서식: 2.4
2022-12-13 15:24:48.824 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(33) 날짜/시간 서식: 2022년 12월 13일 15시 24분 48초
14. getChars(int srcBrgin, int srcEnd, char [] dst, int dstBegin) / void
문자열의 일부 범위를 character형의 배열로 반환한다.
15. hashcode
- 문자열을 해시코드 형태로 반환한다.
16. indexOf(String s)
- 특정 문자나 문자열에서 해당하는 문자의 인덱스 값을 반환, 없으면 -1 반환한다.
public static void main(String[] args) {
String str = "Good Java Programing";
LOGGER.debug("" + str.indexOf("Java"));
LOGGER.debug("" + str.indexOf("apple"));
}
2022-12-13 16:01:18.273 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(15) 5
2022-12-13 16:01:18.275 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(16) -1
17. lastIndexOf(String s)
- 특정 문자나 문자열에서 해당하는 문자를 뒤에서 부터 찾아 인덱스 값을 반환, 없으면 -1 반환한다.
18. isEmpty()
-문자열의 길이가 0이면 true, 아니면 false 반환한다.
public static void main(String[] args) {
String str = "Good Java Programing";
String str2 = "";
LOGGER.debug("" + str.isEmpty());
LOGGER.debug("" + str2.isEmpty());
}
2022-12-13 16:05:50.282 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(16) false
2022-12-13 16:05:50.284 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(17) true
19. length()
문자열의 길이를 반환한다.
public static void main(String[] args) {
String str = "Good Java Programing";
LOGGER.debug("" + str.length());
}
2022-12-13 16:21:57.775 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(14) 20
20. matches (String regx)
정규식과 문자열이 일치하는지 확인한다.
public static void main(String[] args) {
String str = "Good Java Programing";
String str2 = "Good Python Programing";
LOGGER.debug("문자열이 일치한가? : " + str.matches("(.*)Java(.*)"));
LOGGER.debug("문자열이 일치한가? : " + str2.matches("(.*)Java(.*)"));
}
2022-12-13 16:25:34.194 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(16) 문자열이 일치한가? : true
2022-12-13 16:25:34.197 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(17) 문자열이 일치한가? : false
21. replace(charSequence target, charSequence replacement)
바꿀 대상(target)을 replacement로 대체한다.
public static void main(String[] args) {
String str = "Good Java Programing";
LOGGER.debug("str.replace('Java', 'Python') >> " + str.replace("Java", "Python"));
}
2022-12-13 16:29:36.065 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(15) str.replace('Java', 'Python') >> Good Python Programing
22. replace(String regx, charSequence replacement)
바꿀 대상을 replacement로 모두 대체한다. 이때 바꿀 대상이 단어가 아닌 정규식 기준이라는 점이 replace와 다르다.
23. replaceAll( String regex, String replacement ) / String
24. spilt (String regex)
정규식에 따라서 문자열을 나눠준다.
25. subString(int beginIndex)
beginIndex의 인덱스부터의 문자열 반환한다.
public static void main(String[] args) {
String str = "Good Java Programing";
LOGGER.debug("str.substring(5) >> " + str.substring(5));
}
2022-12-13 16:47:03.841 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(15) str.substring(5) >> Java Programing
26. toLowerCase()
문자열을 모두 소문자로 변환한다.
27. toUpperCase()
문자열을 모두 대문자로 변환한다.
28. startWith(String prefix)
비교 대상 문자열이 입력 문자열 값으로 시작하면 true, 아니면 false값 반환한다.
29. endWith(String suffix)
비교 대상 문자열이 입력 문자열 값으로 끝나면 true, 아니면 false값 반환한다.
30. trim()
문자열의 공백을 없애준다.
public static void main(String[] args) {
String str = " Good Java Programing ";
LOGGER.debug("[" + str + "]");
LOGGER.debug("[" + str.trim() + "]");
}
2022-12-13 16:52:52.874 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(15) [ Good Java Programing ]
2022-12-13 16:52:52.878 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(16) [Good Java Programing]
31. toCharArray()
- 문자열을 한 글자씩 쪼개서 이를 char 타입의 배열에 넣어준다.
public static void main(String[] args) {
String str = "Programing";
char[] charArr = str.toCharArray();
for(int i = 0; i < charArr.length; i++) {
LOGGER.debug(charArr[i]+"");
}
}
2022-12-13 16:56:58.622 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(17) P
2022-12-13 16:56:58.625 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(17) r
2022-12-13 16:56:58.626 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(17) o
2022-12-13 16:56:58.626 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(17) g
2022-12-13 16:56:58.626 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(17) r
2022-12-13 16:56:58.626 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(17) a
2022-12-13 16:56:58.627 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(17) m
2022-12-13 16:56:58.627 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(17) i
2022-12-13 16:56:58.627 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(17) n
2022-12-13 16:56:58.627 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(17) g
32. valueOf()
괄호안의 해당 객체를 String 객체로 변환시켜준다.
public static void main(String[] args) {
String str1 = "1234";
String str2 = String.valueOf(10);
String str3 = String.valueOf(3.14);
String str4 = String.valueOf(true);
LOGGER.debug(str1);
LOGGER.debug(str2);
LOGGER.debug(str3);
LOGGER.debug(str4);
LOGGER.debug(str1+str2+str3+str4);
}
2022-12-13 17:01:14.409 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(18) 1234
2022-12-13 17:01:14.412 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(19) 10
2022-12-13 17:01:14.412 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(20) 3.14
2022-12-13 17:01:14.412 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(21) true
2022-12-13 17:01:14.412 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(22) 1234103.14true
33.toString()
상위 클래스인 Object클래스가 가진 toString 메서드를 오버라이딩하여 사용
객체가 가지고 있는 정보나 값들을 문자열로 만들어 반환한다.
class Person {
private String name;
private int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
@Override
public String toString() {
return "이름 : " + name + " 나이: " + age;
}
}
public class StringMethodTest {
private static Logger LOGGER = LoggerFactory.getLogger(StringMethodTest.class);
public static void main(String[] args) {
Person person = new Person("이순신",20);
LOGGER.debug(person+"");
}
}
2022-12-13 17:16:03.364 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(32) 이름 : 이순신 나이: 20
자바의 자료형에는 총 8개의 기본 타입(primitive type)이 있다.
byte, short, int, long, float, double, char, boolean
여기서의 wrapper란 우리가 음식물을 포장할 때 쓰는 '래퍼(호일이라고 말하는 게 좀 더 이해하기 쉬우려나...?)'를 의미한다. 자바에 맞게 의역하면 기본타입을 객체 형태로 '포장'하는 것을 의미한다. 처음 래퍼 클래스라는 단어를 들었을 때 다소 생소하다고 느꼈는데, 생각보다 자신도 모르게 흔하게 쓰고 있었다(이게 정말 문제다).
Generic(제네릭)
정해진 형식에 의존하지 않고, 클래스 외부에서 접근할 때의 재사용성을 높이 위해 사용하는 제네릭. 가령 ArrayList<Integer> xx처럼 컬렉션 형태의 변수를 선언할 때, 제네릭 타입의 <Integer>가 자바의 int 자료형과 매핑되는 래퍼 클래스이다.
Casting(형 변환)
String 형태인 정수 타입의 변수를 int 형태의 기본 타입으로 casting 할 때, Integer 래퍼 클래스의 parseInt()라는 메소드를 사용하여 캐스팅을 진행한다.
String str = "2";
int strToInt = Integer.parseInt(str);
상단에 적어놓은 자바의 8개의 자료형은 다음과 같은 wrapper class와 서로 mapping 된다. 대부분 primitive 타입의 첫 글자만 대문자로 바꾼 형태지만, int, char만 예외적이니 이 두 개의 래퍼 클래스를 사용할 때만 유의하면 된다.
Primitive type과 Wrapper class는 상호 변환이 이루어지는데, 이러한 과정을 각각 boxing과 unboxing이라고 칭한다.
boxing(박싱) : 기본 타입에서 wrapper 클래스로 전환
unboxing(언박싱) : wrapper 클래스 객체를 기본 타입으로 전환
Integer num = new Integer(17); // 박싱
int n = num.intValue(); //언박싱
System.out.println(n);
자바에서는 JDK 1.5 버전으로 들어와서 자동으로 boxing / unboxing을 해준다.
int i = 1;
Integer integer = i; // int -> Integer ( Auto boxing )
int i2 = integer; // Integer -> int ( Auto unboxing )
public static void main(String[] args) {
Integer num = new Integer(10);
Integer num2 = new Integer(10);
int i = 10; // 기본타입
LOGGER.debug("래퍼클래스 == 기본 : "+(num == i)); // true
LOGGER.debug("래퍼클래스.equals(기본) : "+num.equals(i)); // true
LOGGER.debug("래퍼클래스 == 래퍼클래스 : "+(num == num2)); // false
LOGGER.debug("래퍼클래스.equals(래퍼클래스) : "+num.equals(num2)); // true
}
2022-12-13 17:46:33.722 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(25) 래퍼클래스 == 기본 : true
2022-12-13 17:46:33.726 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(26) 래퍼클래스.equals(기본) : true
2022-12-13 17:46:33.726 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(27) 래퍼클래스 == 래퍼클래스 : false
2022-12-13 17:46:33.726 [DEBUG] [ main] com.barunsw.ojt.jmlee.day02.StringMethodTest(28) 래퍼클래스.equals(래퍼클래스) : true
[인턴 OJT 6일차] File I/O , DBAddressImpl 수정 및 복습 (0) | 2022.12.20 |
---|---|
[인턴 OJT 5일차] Java DB 연동 select, insert (0) | 2022.12.16 |
[인턴 OJT 4일차] 직렬화 ( serialization ), file i/o 기반 주소록 (0) | 2022.12.15 |
[인턴 OJT 3일차] Static, File I/O, Static, bit/byte (0) | 2022.12.14 |
[인턴 OJT 1일차] 개발환경 구성, maven, Log4j, coding standard (0) | 2022.12.12 |
댓글 영역