1
public static void printsubset(ArrayList<ArrayList<Integer>> s) {
    for(ArrayList s1 : s) {
        for(Integer s2 : s1) {
            System.out.println(s2);
        }
    }
}

in the inner for loop i am getting type mismatch.s1 is of the type object .how do i convert it arraylist

default locale
  • 13,035
  • 13
  • 56
  • 62
backcoder
  • 57
  • 7

1 Answers1

2

You need to specify in the first for each loop that s1 is an ArrayList<Integer> not just an ArrayList (which would imply an ArrayList of Objects.

public static void printsubset(ArrayList<ArrayList<Integer>> s) {
    for(ArrayList<Integer> s1 : s) {
        for(Integer s2 : s1) {
            System.out.println(s2);
        }
    }
}
NESPowerGlove
  • 5,496
  • 17
  • 28
  • but that i have already defined it while initialising.is it not enough?@NESPowerGlove.Anyways thanks it works – backcoder Jan 15 '15 at 18:47
  • You must also specify in loop otherwise all it knows is it is getting an `arraylist` for all it knows it could be `String` `Integer` `Double` – brso05 Jan 15 '15 at 18:49
  • @bro05 thanks for making me understanding this logic – backcoder Jan 15 '15 at 18:53