Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java check if string appears twice in arraylist

//same as the Grepper awnser but for anything
//gets the amount of times the object appears in the array
public static int amountOfTimesObjectAppearsInArray(ArrayList<?> array, Object checkMe) {
    int numCount = 0;
    for (Object o : array) {
        if (o.equals(checkMe)) numCount++;
    }
    return numCount;
}
//check if it appears more than once
public static boolean objectAppearsInArrayMoreThanOnce(ArrayList<?> array, Object checkMe) {
    return amountOfTimesObjectAppearsInArray(array, checkMe)>1;
}
Comment

PREVIOUS NEXT
Code Example
Java :: linear serach in java 
Java :: java store data 
Java :: java add two arrays together 
Java :: how to create textview in java android 
Java :: FlutterFirebaseCorePlugin.java uses or overrides a deprecated API. 
Java :: groovy if else 
Java :: the import junit cannot be resolved maven 
Java :: hashtable in java 
Java :: java add constructor to enum 
Java :: java linked list swap elements 
Java :: java boolean data type 
Java :: capture console output java 
Java :: room insert and return id 
Java :: get string size 
Java :: can we override the overloaded method in java 
Java :: iterate through arraylist java 
Java :: array to array list java 
Java :: class property java 
Java :: POST method) in spring rest api 
Java :: how to divide a double in java 
Java :: instanceof java 
Java :: method overriding java 
Java :: output folder director 
Java :: how todo a timeout test java 
Java :: teimpo en segundos java 
Java :: how to set credentials for speechClient Java google api 
Java :: Kadane Algorithm for maximum sub-array 
Java :: Android number format thousands separator 
Java :: string to integer online 
Java :: assigning value with for each 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =