class A contain:
public static ArrayList<String> sourceList = new ArrayList<String>();
// here ArrayList contain some string type data;
public static ArrayList<String> getSource()
{
return sourceList;
}
main class contain:
List<String> s1 = A.getSource();
for(String dk:s1) {
System.out.println(dk);
}
Here I am storing ArrayList data of class A into a list in class B and checking
whether its works or not.but when I run the main class it gives nothing.
thanks.
I’ve simulated what you are doing, and it’s working as expected. Are you sure the list is being populated correctly?