I expect this program to print this result:
[john, smith, 85]
[michol, smith, 65]
[benz, red, 90]
but output of this program is:
[]
[]
[]
please help me to correction that.
package javaapplication12;
import java.util.ArrayList;
public class JavaApplication12
{
public static void main(String[] args)
{
String[] l=new String[3];
l[0]="benz black 85";
l[1]="BMW red 56";
l[2]="benz red 90";
ArrayList<ArrayList<String>> ss = new ArrayList<ArrayList<String>>();
ArrayList<String> s = new ArrayList<String>();
for(int j=0; j<3; j++)
{
String[] part=l[j].split(" ");
for(int i=0; i<3; i++)
s.add(part[i]);
ss.add(s);
s.clear();
}
System.out.println(ss.get(0));
System.out.println(ss.get(1));
System.out.println(ss.get(2));
}
}