Operation | Code |
---|---|
New List |
List<Integer> x = new ArrayList<Integer>(); |
Copy List |
List<Integer> x = new ArrayList<Integer>(y); |
Add an element to the List |
x.add(element) |
Get an elemenet from the List |
x.get(index) |
Clear the list | x.clear() |
New HashMap |
HashMap<Integer, String> x = new HashMap<Integer, String>(); |
Add element to the map | x.put(key, value) |
Get an element from the map | x.get(key) |
Declare a class | public class Ideone extends Main implements Runnable { ... } |
Declare a function | public static List<String> weave(String a1, String a2) |
Append to a StringBuilder |
StringBuilder b = new StringBuilder();b.append(...); |
Prepend to a StringBuilder |
b.insert(0, "text"); |
Get a substring from a string | str.substring(i, j) |
Created
December 17, 2018 14:48
-
-
Save Adria87/8e5b8bbd982566965a685d0faefd7569 to your computer and use it in GitHub Desktop.
[Java cheatsheet] #java
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment