What am I doing wrong? : >I keep getting an out of bounds error. Want to check for duplicates. there is more after this, but for right now all thats important. its for a school project. it says the the Array list is index:1 size: 1 out of bounds exception






ArrayList <Integer> lottery = new ArrayList<Integer>();
        
      
        for (int n=0; n<4;)
       { 
        int number = 0;
        int first = 0;
        int value = 0;
        boolean found = false;
        first =(int)(Math.random()*42 +1);
        lottery.add(first);
        count[first]++;
        
      
        for (int i=1; i<6;)
        {
            number = (int)(Math.random()*42 +1);
             
            for(int k = 0; k<6; )
            {
                   // here value = lottery.get(k);
                    if (value == number)
                    {
                        found = true;
                         
                    }
                    else
                    {
                        found = false;
                    }
                    
                    if (found == true)
                          { 
                              number = (int)(Math.random()*42 +1);
                              
                          }
                          else 
                          {
                                k++;
                
                        }
                  
                  
                      
                }
                System.out.println("number " + (i+1) + ": " + number);
            if ( found == false)
        
                {
                    lottery.add(number);
                    count[number] ++;
                    i++;
                    
                    
                }
           
        }