
/*
Online Java - IDE, Code Editor, Compiler

Online Java is a quick and easy tool that helps you to build, compile, test your programs online.
*/

public class Main
{
    public static void main(String[] args) {
        System.out.println("Welcome to Online IDE!! Happy Coding :)");
        int []nums = new int[]{100,4,200,1,3,2};
        int setStart=0;
        int differenceCheck=1;
        int count=0;
        boolean nextnumberconsecutive;
        
        for (int i=0; i< nums.length; i++)   // this will go through each element in array
        {
            System.out.println("This is the number being checked: " + nums[i]);
            differenceCheck=1;
            
            for (int j=0; j<nums.length; j++)  // this is used to compare each element to all others except itself
                                               // However this is not a sufficient loop since if the next consecutive integer is found,
            {
                if (j==i)
                {
                    j++;
                }
                
                if (j!=nums.length)
                {
                    
                    if (nums[j]==nums[i]+differenceCheck)
                    {
                        do
                        {
                        //setStart=0;
                        differenceCheck++;
                        System.out.println("this is next number:" + nums[j]);
                        count++;
                        
                        nextnumberconsecutive = nextnumbercheck(nums[j]+1, nums);
                        System.out.println("this is the boolean output:" + nextnumberconsecutive);   
                        }while(nextnumberconsecutive==true);
                        
                        Exit
                       
                    }
                }
            }
        }
    }
    
    static boolean nextnumbercheck(int nextNum, int[] nums)
    {
        for (int i=0; i<nums.length; i++)
        {
            System.out.println(nextNum-1 + " will be checked against remaining loop");
            
            if (nums[i]==nextNum-1)
            {
                i++;
                
                //System.out.println("ever reach");
                
            }
            
            if (i!=nums.length)
            {
            
            if (nextNum==nums[i]-1)
            {
                System.out.println("This should find: " + nextNum);
                System.out.println("This is next number: " + (nums[i]-1));
                return true;
            }
        }
    }
        return false;
    }
    
}
