Reputation: 427
I have created 2 tables(which i am reading from a 2 diffrent files ) and inserted values into lists .now i want to join table such that (I have attached image)
Record 1:Faculty SID Faculty Courses F_Home Phone H_Work Phone
Record 2; SID Age Home Phone Work Phone PH No
Final: Faculty SID Faculty Courses F_Home Phone H_Work Phone SID Age Home Phone Work Phone PH No
while(s.hasNext())
{ String field1=s1.next();
String field=s.next();
values.add(field);values1.add(field1);
for(String x:values)
{list1.add(x);
}
for(String y:values1)
{
list2.add(y);
}
}
List<String> newArray = new ArrayList<String>();
newArray.addAll(list1);
newArray.addAll(list2);
for(int h=0;h<100;h++)
{
System.out.printf("%s",newArray.get(h)+ "\n");
}
Upvotes: 1
Views: 867
Reputation: 2225
Use Guava's:
Iterables.concat(Iterable<T>... list)
Guava could be included using maven:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>11.0.1</version>
</dependency>
Upvotes: 4