Q:

List values is not displaying for more rows

List is not displaying more no of records > ihave read data from 2 excel files and when i run the follwing program it is showing only 1 row when there are 50 rows.
Scanner s= new Scanner(fil); // reading from file 
String array1[]=new String[50];
s.next(); s.next(); s.next(); s.next();
int i=0;
String[] values= new String[55];
while(s.hasNext())
{  
  String field=s.next();
  values=field.split(","); 
}
List<String> list1=new ArrayList<String>();

for(String x:values)
{
  list1.add(x);
}
System.out.println(list1);

A:

There is a proper reason for that:
You iterate the rows with the scanner all right, but then you replace the values array in each iteration. Thus you will get only the last row in values eventually.
You might do it like that:
List<String> values = new ArrayList();
while(s.hasNext())
{  
  String field=s.next();
  for (String value : field.split(",")) {
     values.add(value);
  }
}

