I want to exit from two for loops when count become 9. I use break for that but it can exit from only the first for loop. How can it done? 
       ArrayList<String> list = new ArrayList<String>();
        int count = 0;
        System.out.println("Before entering to loop");
        for(int i=0;i<5;i++){
            list.add("XYZ"+i);
            for( int j=0;j<5;j++){
                list.add("ABC"+j);
                count++;
                if(count==9){
                    System.out.println("I want to exit from here.");
                    break;
                }
                System.out.println("i="+i+"::j="+j);
            }
            System.out.println("------------");
        }
        for(String str:list){
            System.out.println(str);
        }
    }
 
     
     
     
     
     
     
    