Results 1 to 3 of 3
  1. #1
    yuvi461 is offline Member
    Join Date
    Jan 2008
    Posts
    3
    Rep Power
    0

    Post 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

  2. #2
    Swamipsn is offline Member
    Join Date
    Jul 2007
    Posts
    74
    Rep Power
    0

    Default

    for(int i=0;i<5;i++)

    {
    System.out.print(id[i]);
    System.out.print(name[i]);
    System.out.print(dept[i]);
    }
    System.out.print();
    }

    }

    Its make any sense..?

  3. #3
    yuvi461 is offline Member
    Join Date
    Jan 2008
    Posts
    3
    Rep Power
    0

    Default

    actually my problem is i have to make a list and then i have to sort it.so only as a first step i asked in that manner.i m a beginner so forgive me for that cheap question.

Similar Threads

  1. How to display image ?
    By Birkoff in forum AWT / Swing
    Replies: 7
    Last Post: 06-09-2008, 08:58 AM
  2. GUI components not display
    By Eranga in forum AWT / Swing
    Replies: 2
    Last Post: 03-12-2008, 03:16 AM
  3. SWT Display class
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-30-2007, 01:19 PM
  4. Adding List to MIDlet Display
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-23-2007, 03:07 PM
  5. Display program
    By nhlfan in forum New To Java
    Replies: 2
    Last Post: 11-22-2007, 01:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •