Better_Java_Cheat_Sheet
Better_Java_Cheat_Sheet
Array
- arr.length
- Arrays.sort(arr);
- Arrays.copyOf(arr, len);
ArrayList
- list.add(value);
- list.add(index, value);
- list.get(index);
- list.set(index, value);
- list.remove(index);
- list.contains(value);
- list.size();
- list.clear();
- list.indexOf(value);
- list.isEmpty();
- list.toArray();
LinkedList
- list.addFirst(value);
- list.addLast(value);
- list.removeFirst();
- list.removeLast();
- list.peekFirst();
- list.peekLast();
HashSet
- set.add(value);
- set.remove(value);
- set.contains(value);
- set.isEmpty();
- set.size();
TreeSet
- tree.add(value);
- tree.first();
- tree.last();
- tree.floor(value);
- tree.ceiling(value);
HashMap
- map.put(key, value);
- map.get(key);
- map.containsKey(key);
- map.containsValue(value);
- map.remove(key);
- map.keySet();
- map.values();
- map.entrySet();
TreeMap
- map.firstKey();
- map.lastKey();
- map.lowerKey(key);
- map.higherKey(key);
Queue (LinkedList)
- queue.add(value);
- queue.poll();
- queue.peek();
- queue.isEmpty();
Deque (ArrayDeque)
- deque.addFirst(value);
- deque.addLast(value);
- deque.removeFirst();
- deque.removeLast();
- deque.peekFirst();
- deque.peekLast();
Stack
- stack.push(value);
- stack.pop();
- stack.peek();
- stack.isEmpty();
PriorityQueue
- pq.add(value);
- pq.poll();
- pq.peek();
String
- str.length();
- str.charAt(index);
- str.substring(start, end);
- str.indexOf(sub);
- str.lastIndexOf(sub);
- str.contains(sub);
- str.equals(other);
- str.equalsIgnoreCase(other);
- str.toLowerCase();
- str.toUpperCase();
- str.trim();
- str.replace(old, new);
- str.split(delimiter);
- String.valueOf(x);
Utilities
- Arrays.sort(array);
- Arrays.binarySearch(array, value);
- Arrays.equals(arr1, arr2);
- Collections.sort(list);
- Collections.reverse(list);
- Collections.max(list);
- Collections.min(list);
- Collections.frequency(list, item);