how to check if an arraylist contains a value in java recursion
public static boolean contains(ArrayList<Integer> list, int value) {
return contains(list, value, 0);
}
private static boolean contains(ArrayList<Integer> list, int value, int idx) {
boolean hasInt = false;
if (idx < list.size()) {
if (list.get(idx) == value) {
hasInt = true;
} else {
hasInt = contains(list, value, idx + 1);
}
}
return hasInt;
}
Also in Java:
- how to check the end of a string java
- how to count an replace string in java
- append to arraylist by index java
- fibonacci sequence in java recursion
- how to select a random element from an array in java
- add certificate to java truststore
- how to know when user is done typing android
- java remove double spaces
- download spring
- how to check if an arraylist contains a value in java recursion
- jtable disable row selection
- java infinitew recursion
- array string java in one line
- java create unmodifiable list
- java unique id
- system.in example in java
- java 8 string to localdate
- Matlab java.lang.IllegalArgumentException: Invalid range
- java string is null or empty
- sdkmanager JAVA_HOME invalid directory
- while loop java
- java fullscreen jframe
- java observable to observer stack overflow
- index of an array procesing