Monday, 7 May 2018



//Nesting of for each loop...............

import java.util.ArrayList;
import java.util.List;

public class ListDemo1 {
     public static void main(String[] args) {
     List<Integer> l1=new ArrayList<>();
     l1.add(10);
     l1.add(20);
     l1.add(30);
     List<Integer> l2=new ArrayList<>();
     l2.add(10);
     l2.add(40);
     l2.add(50);
     l2.add(60);
     System.out.println("-------------o/p-----------------");
    
     for(Integer i1:l1)
     {
           for(Integer i2:l2)
           {
               
                if(i1<i2)
                {
                     System.out.println(i1+" ");
                }
           }
     }
    
     }

}


o/p:----------------------------
10
10
10
20
20
20
30
30
30

No comments:

Post a Comment