|
To display as a list
import java.io.*;
import java.util.*;
class Arry
{
public static void main (String args[])throws Exception
{
int id[]=new int[5];
String name[]=new String[5];
String dept[]=new String[5];
BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
for(int i=0;i<5;i++)
{
System.out.println("Enter Id");
id[i] = Integer.parseInt(br.readLine());
System.out.println("Enter New name");
name[i]=br.readLine();
System.out.println("Enter Department");
dept[i]=br.readLine();
}
//Arrays.sort(name);
for(int i=0;i<5;i++)
{
System.out.println(id[i]);
System.out.println(name[i]);
System.out.println(dept[i]);
}
}
}
in this program the output will be id,name,dept and goes on until the loop completes.my problem is how could i display it as a table (ie) the corresponding name,id,dept should be printed in the same line.please anybody suggest me a option
|