Here you can find the source of containsOnlySequentialNumbers(List
public static boolean containsOnlySequentialNumbers(List<Integer> values)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { public static boolean containsOnlySequentialNumbers(List<Integer> values) { for (int i = 0; i < values.size() - 1; i++) { if (values.get(i) != values.get(i + 1) - 1) { return false; }//from w ww.ja v a 2s .c o m } return true; } }