import java.util.*;

/*
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
{
    static boolean completeOnce=false;
    static int []nums = new int[]{100,4,200,1,3,2};
    static int[][] Store = new int[nums.length][nums.length];
    static int[][] temp = new int[nums.length][nums.length];
    
    static int differenceCheck=1;
    static int count=0; // this keeps track consecutive numbers.
    static int firstNum;
    
    
    
    static boolean multipleMaxLength=false;
    
    static int nextNum;
    static int q;
    static int p;
    
    
    public static void main(String[] args) {
        System.out.println("Welcome to Online IDE!! Happy Coding :)");
      
      
     
        
    boolean nextnumberconsecutive;
        
    int maxConsecutive=0;
    
    for (int i=0; i< nums.length; i++) // this will go through each element in array
    //it is safe to say when the inner loops have not succeeded, it will start here again since the consecutive streak is broken...
    //so it should have a fresh store.....
    
    {
        //Store = new int[nums.length];
        
        Store[i][count]=nums[i];
        
        System.out.println("\nThis 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 array element in previous loop
        // However this is not a sufficient loop since if the next consecutive integer is found,
        // it would not continue process to check for next consecutive.
        //Hence another nested loop required for array elements k
        {
            
            
            if (j==i) // this will prevent same number being compared and increment inner loop by 1. 
            //However not critical since identical array element can not interfere
            {
                j++;
                
            }
            
            if (j!=nums.length) //The whole process will continue as long as the inner loop does not exceed the array length
            {
                if (nums[j]==nums[i]+differenceCheck) // if the value in element j  is next consecutive number to value at num[i]
                {
                    count++;  //it is setting next vacant position in the store... it is guaranteed to fill this.....
                    
                    do // perform this loop whilst elements of the array are searched in order to find j element residing at   i + differenceCheck;
                    {
                        
                        // seeking the next consecutive number
                        
                        System.out.println("***Next consecutive number has appeared:***" + (nums[i]+differenceCheck) + "This should be same as nums[j]");
                        //nextnumberconsecutive = nextnumbercheck(nums[i]+differenceCheck, nums, count, Store);
                     
                        
                        Store[i][count]= nums[i]+differenceCheck;  //stores next consecutive number
                        //note Store[0] is reserved for nums[i]
                        
                        differenceCheck++; // this will ensure next time this loop is entered, the initial number will be compared
                        
                        nextNum = nums[i]+differenceCheck;  //next consecutive number expected....
                        
                        //method call...
                        nextnumberconsecutive = nextnumbercheck(i);
                        
                        
                        
                        //this calls a method. It will ensure that next searching of array elements will find element differenceCheck from initial array element
                        
                       
                        
                        
                        //System.out.println("this is the boolean output:" + nextnumberconsecutive);
                        
                        //this is needed so that it is ready to start fresh again...
                        //otherwise for instance if the array consisted of   1,2,3,6,5  
                        //it would continue to process from 6 onwards..
                        //it would also fail to clear the store repository of consecutive numbers...
                        
                        j=nums.length-1;
                    
                    //this has become a bit messy since the differenceCheck was referenced from i
                    //if it was done against j, might have been a bit tidier..
                    }while(nextnumberconsecutive);
                    
                }
                }
            
        }  //end of inner for loop
        
    }  //end of for loop going through all nums
   
   System.out.println("Length of store: " + Store.length);
   int counter=0;
   int consecutiveNumbers=0;

System.out.println("********These are all entries*********");

for (int max[]: Store)   //for each row in store...
{
    
    System.out.println(Arrays.toString(max));

}

//it all functions up to here...
//was attempting a way to check which array has consecutive numbers utilisng integer array
//However it proved to be a bit tricky.
//I didn't want to jeopardise fluidity of my code...
//So on this instance, just used string manipulations..
//using integers almost created another challenge...

int m=0;
String []MaxConsecutiveArrays = new String[nums.length];
StringJoiner sj = new StringJoiner(",");
int pos=0;
String formattedNum;


for (int max[]: Store)   //for each row in store...
{
    for (int k: max)
    {
        sj.add(Integer.toString(k)
        
    }
    temp[pos]=sj.toString();
    sj=new StringJoiner(",");
    
    pos++;

}


for (String s: temp)   //for each row in store...
{
    for (char k: s)
    {
        zerFoundLocation= s.indexOf('0');
        continue;
        
    }
    
    if (zerFoundLocation>0)
    {
        formattedNum = s.substring(0,zerFoundLocation);
        temp[i]=
    }
    

}




/*
int currentConsectiveNumbers=0;
StringJoiner sj = new StringJoiner(",");
String numtoString;
boolean conditionOnce=false;
int currentI=0;
int j=0;
int zerFoundLocation=0;
boolean multipleSame=false;
boolean zeroFound=false;
int posZero=j;


for (int i=0; i<Store.length; i++)   //each row
{
    System.out.println("\n******NEW NUMBER*****:  " + Arrays.toString(Store[i]));
    System.out.println("this is current highest consecutiveNumbers: " + currentConsectiveNumbers);
    
    sj=new StringJoiner(",");  //creates StringJoiner
    
    //conditionOnce=false;  // it will set this on start of new row...
    // this will enable it to check for 0's again.....
    
    
    for (j=0; j<Store[0].length; j++)  //each column in row.....
    {
        numtoString=Integer.toString(Store[i][j]); //this gets overwritten 
        zeroFound=false;
        conditionOnce=true;
        
        sj.add(numtoString); //keeping all numbers into a new StringJoiner...
        
        //if it finds a 0 and not at first location (since it could be a genuine 0 in the array)
        if (Store[i][j]==0 && j!=0)
        {
            System.out.println("************HERE***********");
            System.out.println("zero found at: " + j); // this is correct
            
            posZero=j;
            counter++;
            //conditionOnce=true;
            
            if (j>zerFoundLocation)
            {
            zerFoundLocation=j;
            }
            
            zeroFound=true;
            j=nums.length;
            
            if (conditionOnce)
            {
                System.out.println("fdsfdsfd: " + Arrays.toString(Store[i]));
            currentConsectiveNumbers=zerFoundLocation;
            conditionOnce=false;
            }
        }
        
        //if position of the 0 is greater than previous entry.
        //note due to 0 indexing, the position of the first 0 determine the length of the consecutive numbers
        //prior to it..
        
        //System.out.println("What is happening here: " + currentConsectiveNumbers);
        
        if (zerFoundLocation>currentConsectiveNumbers &&zeroFound)
    {
        System.out.println("************HERE1***********");
         System.out.println("this is current highest consecutiveNumbers: " + currentConsectiveNumbers);
         System.out.println("this is identified consecutive Numbers: " + zerFoundLocation);
        
        temp = new String[nums.length];  //clears all existing entries... 
        //currentConsectiveNumbers=j;
        temp[0]=sj.toString();
        
        System.out.println("string: " + temp[i]);
        currentI=i;
        counter++;
        
        break;
    }
    
    //this will create indefinite loop.. hence it checks if i has changed...
    if (zerFoundLocation==currentConsectiveNumbers && i!=currentI &&zeroFound)
    {
        System.out.println("************HERE2***********");
        currentConsectiveNumbers=zerFoundLocation;
        temp[i]=sj.toString();
        counter++;
        multipleSame=true;
        
        break;
        //j=nums.length;
     }
     
    
    }
     
     //issue is that the first set of numbers stored in repository will exceed currentConsectiveNumbers
     //and then if there is another greater, it will be stored.
     //so there are two rows...
     //can discard all the rows with null...
     
}

System.out.println("Longest consecutive: " + currentConsectiveNumbers);
         
         for (String s: temp)
         {
             //if (s!=null)
             //{
                 System.out.println(s);
                 break;
             //}
         }
         
         */
}
  //                            (nums[i]+differenceCheck, nums,  differenceCheck (2),   contains array for differenceCheck)
//static boolean nextnumbercheck(int nextNum, int[] nums, int differenceCheck, int[] Store)
static boolean nextnumbercheck(int firstNum)
{
    //int [][]temp = new int[nums.length][nums.length];
    
    // this is doing all of nums again..... since the numbers are out of order...
    //it is comparing the j value (which is i+ differenceCheck and hoping to find   next value at  i+differenceCheck (which has been incremented...))

    for (int i=0; i<nums.length; i++)   
    {
        
        System.out.println(Store[firstNum][count] + " will be checked against numbers for next consecutive number: " + nextNum);
        //if (i!=nums.length)  // why is this condition here, its not in a position to exceed array?
        //{
            if (nextNum==nums[i])   //if it finds a match....
            {
            System.out.println("Found next consecutive number: " + nextNum);
            
            System.out.println("COUNT!!!!: " + count);
            
            count++;
            Store[firstNum][count]=nextNum;   // number stored in next free position...
            
            return true;
                
            }
        
    }
    
    count=0;
    differenceCheck=1;
    
    return false;
    
}
    
}