오늘까지만은 없다
JAVA
오늘만, 오늘까지만은 없다
· JAVA/study
import java.util.*;public class ComparatorExample { public static void main(String[] args) { List list = Arrays.asList("apple", "banana", "kiwi", "grape"); Collections.sort(list, new Comparator() { @Override public int compare(String o1, String o2) { return o1.compareTo(o2); // 사전식 정렬 } }); System.out.println(list); ..
· JAVA/study
String str3 = new String("Hello");  1. 문자열 생성Java에서 문자열을 생성하는 과정은 크게 2가지 방법이 있다.- String literal- new String()두개는 어떤 차이를 가지고 있을까?   2. String LiteralString str1 = "Hello";String str2 = "Hello";String Literal은 문자열을 생성하는 가장 간단하고 일반적이 방법이다. 이 방식은 문자열을 큰 따옴표(" ") 로 둘러싸서 표현한다.   String Literal 방식으로 문자열을 생성하면, JAVA Heap 메모리 영역의 문자열 상수 풀(String Constant Pool) 영역에 값이 저장이 된다.   3. new String()String str3..
· JAVA/study
Static 변수란?static 변수는 클래스 수준에서 선언할 수 있고, 클래스의 모든 인스턴스에서 공유된다. 즉, 하나의 static 변수가 모든 객체에서 사용된다.이게 도대체 무슨말인가.. 바로 코드를 작성해서 알아보았다.Static 변수 예시public class Counter { // static 변수 선언 public static int staticCount = 0; // 변수 선언 public int count = 0; public Counter() { staticCount++; // static 변수 count 증가 count++; // 일반 변수 count2 증가 }먼저, 차이를 한눈에 알아보기 위해 `static`으로 선언한 변수..
Maltyy
'JAVA' 카테고리의 글 목록