Import
import java.util.*;
import java.io.*;
Sort 함수
int[] arr = {1, 3, 5, 4, 2}
Arrays.sort(arr);
Math 함수
int answer = 1;
answer = Math.max(answer, 100);
answer = Math.min(answer, 100);
answer = Math.abs();
Math.ceil(-3.2);
Math.floor(-3.2);
Math.round(-3.26);
double a = 1.2345;
String b = String.format("%.1f", a);
Math.pow(2, 2);
Maht.sqrt(4);
Arrays
int[] arr = {3, 4, 2, 5, 1};
Arrays.sort(arr);
Arrays.sort(arr, Collections.reverseOrder());
Arrays.sort(arr, 0, 4);
Arrays.binarySearch(arr, 2);
List list = Arrays.asList(Arr);
int[] tmp = Arrays.copyOfRange(arr, 0, 3);
length / length() / size()
- length: array의 길이 (arr.length)
- length(): String related object (str.length())
- size(): Collections object (list.size())
int[] arr = new arr[3];
System.out.println(arr.length);
String arr = "java";
System.out.println(str.length());
ArrayList<Integer> list = new ArrayList<>();
System.out.println(list.size());
String
String str = "hello world";
str.split(" ");
str.substring(0, 5);
for(int i=0; i<str.length(); i++) str.charAt(i);
String str = "12345";
String[] Arr = str.split("");
str = str.toUpperCase();
str = str.toLowerCase();
String name="starfucks";
String newname = name.substring(0, 4) + 'b' + name.substring(5);
HashMap
HashMap<String, Integer> hm = new HashMap<>();
hm.put("java", 0);
hm.get("java");
if (!hm.containsKey("java")) hm.put("java", 1);
hm.put("java", hm.getOrDefault("java", 3));
for (String key : hm.keySet()) {
hm.get(key);
}
ArrayList
ArrayList<String> list = new ArrayList<>();
list.add("java");
list.add(0, "ryu");
list.set(1, "c++");
list.remove(1);
list.contains("java");
list.indexOf("ryu");
Iterator it = list.iterator();
while (it.hasNext()) {
}
while (it.hasPrevious()) {
}
if (list.indexOf(value) < 0) {
list.put(value);
}
for (int i=0; i<list.size(); i++) {
list.get(i).intValue();
}
Queue
Queue<Integer> q = new LinkedList<>();
q.add(10);
q.offer(2);
q.peek();
q.remove();
q.poll();
q.clear();
q.isEmpty();
static class Node{
int y;
int x;
int dist;
Node(int y, int x, int dist){
this.y = y;
this.x = x;
this.dist = dist;
}
}
Queue<Node> queue = new LinkedList<>();
queue.add(new Node(1, 2, 3));
Node node = queue.poll();
PriorityQueue
Queue<Integer> MinHeap = new PriorityQueue<>();
Queue<Integer> MaxHeap = new PriorityQueue<>(comparator.reverseOrder());
heap.add(3);
heap.remove();
heap.peek();