* 형변환
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
public class Main {
public static void main(String[] args) throws Exception {
int a = 65;
System.out.println("Integer to Character : " + (char) a); //A
System.out.println("Integer to String : " + String.valueOf(a)); //65
char ch = '3';
char[] ch2 = {'a','b'};
System.out.println("Character to Integer : " + ((int) ch - '0')); //3
System.out.println("Character to String : " + String.valueOf(ch)); //3
System.out.println("Character to String : " + String.valueOf(ch2)); //ab
String s = "9";
String s2 = "123";
System.out.println("String to Integer : " + Integer.parseInt(s)); //9
System.out.println("String to Character : " + s.charAt(0)); //9
System.out.println("String to Character : " + Arrays.toString(s2.toCharArray())); // [1, 2, 3]
}
}
|
cs |
스텍
Stack<Integer> stack = new Stack<>(); //int형 스택 선언
push
pop
큐
Queue<Integer> queue = new LinkedList<>();
add
poll
우선순위 큐
PriorityQueue<Integer> pq = new PriorityQueue<>();
add
pop
peek
Array
int[] arr = new int[4];
Arrays.sort();
Arrays.sort(arr, Collections.reverseOrder());
arr.length
ArrayList
ArrayList<Integer> alist = new ArrayList<>();
add
remove
get
alist.size();
String[] array = arrayList.toArray(new String[arrayList.size()]); // ArrayList -> Array
ArrayList<String> arrayList = new ArrayList<>(Arrays.asList(array)); // Array -> ArrayList
HashSet
HashSet hs = new HashSet<>();
add(key)
contains(key)
HashMap
HashMap<String, Integer> hm = new HashMap<>();
put(key, value)
get(key)
containsKey(key)
'∙Java' 카테고리의 다른 글
[JAVA] int, char, String 형변환 정리 (1) | 2019.04.30 |
---|---|
[Java] if-else 줄이는 코딩방법 (0) | 2019.01.17 |
[Java] OOP(객체지향 프로그래밍) 특징과 꼬리질문 (0) | 2019.01.12 |
[Java] ==와 equals()의 차이 (0) | 2019.01.10 |