I run a for loop in Java like for(String Day : days)
. I want to print data of for loop outside of for loop. How to do this?
String[] day = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"};
List<String> days = Arrays.asList(day);
Collections.shuffle(days);
for(String Day : days){
//System.out.println(Day + " ");
}
String[] persons = {"john", "Bob", "Smith", "Tom", "Ryan"};
List<String> names = Arrays.asList(persons);
Collections.shuffle(names);
for(String name : names){
//System.out.println(name + " ");
}
I want to print both like System.out.println(name+" " + Day+" "); but it showing error of cannot find symbol. How to fix it?