Checked this out to find Missing number from arraylist:

import java.util.ArrayList;

import java.util.Random;

/*

* Code for missing number from arrayList whereNumbers added randomly

public class MissingNumber {

public static void main(String[] args) {

// declare an ArrayList to hold the random numbers

ArrayList<Integer> myArraylist = new ArrayList<>();

// declare an ArrayList to hold the missing numbers

ArrayList<Integer> missingNumbers = new ArrayList<>();

int maxRanNumb = 10;// random numbers will be 0-9

int size = 20; // size of myArrayList

for (int j = 0; j < size; j++) {

// Generate random numbers

Random rand = new Random();

int randomNumber = rand.nextInt(maxRanNumb);

// Put random numbers into myArrayList

myArraylist.add(randomNumber);

}

// Print myArrayList

System.out.println("Contents of myArraylist: " + myArraylist);

// Search missing number

for (int j = 0; j < maxRanNumb; j++)

if (!myArraylist.contains(j)) {

// Put missing numbers into missingNumbers

missingNumbers.add(j);

}

// Print missingNumbers

System.out.println("Missing numbers is : " + missingNumbers);

}

}

This will help you out!