Basic Syntax Flashcards
for loop
for (statement 1; statement 2; statement 3) {
// code block to be executed
}
number of elements in array
array.length
immutable list w/ literals
List<Integer> list=Arrays.asList(1, 2, 3);</Integer>
char array from String
char[] ch = str.toCharArray();
hash set from list
Set<String> set = new HashSet<>(list);</String>
number of elements in a queue
q.size()
java max function
Math.max
Create a HashMap
private HashMap<Integer, Integer> memo = new HashMap<Integer, Integer>();
Check if HashMap has key
hashMap.containsKey(i)
substring of a string
public String substring(int begIndex, int endIndex);
beginIndex : the begin index, inclusive.
endIndex : the end index, exclusive.
parse string to int
int i=Integer.parseInt(“200”);
number of characters in a string
s.length()
get larges integer values
Integer.MAX_VALUE
insert object into hashset
hashSet.add()
append an element to the end of a list
list.add(E e)