Results 1 to 3 of 3
  1. #1
    Kartiky14 is offline Member
    Join Date
    Mar 2012
    Posts
    10
    Rep Power
    0

    Default Lexicographical arrangement

    import java.util.Scanner;
    class selection1
    {
    public static void main()throws Exception
    {
    Scanner obj = new Scanner(System.in);
    System.out.println("Enter the number of elements-->>");
    int n = obj.nextInt();
    String a[]= new String[n];
    for(String fz:a)
    fz=obj.nextLine();
    for(int i =0; i<a.length ;i++)
    {
    for(int j = i+1;j<a.length;j++)
    {
    if(a[i].compareTo(a[j])>0)
    {
    String temp = a[i];
    a[i] = a[j];
    a[j] = temp;


    }
    }
    }
    for(String o:a)
    System.out.println(o);
    }
    }
    A Null pointer Exception occurs.....!!! Please resolve !!

  2. #2
    gauravfzd's Avatar
    gauravfzd is offline Member
    Join Date
    Oct 2010
    Location
    India
    Posts
    72
    Rep Power
    0

    Default Re: Lexicographical arrangement

    In which line?

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,526
    Blog Entries
    7
    Rep Power
    20

    Default Re: Lexicographical arrangement

    What are the String values stored in the array?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 11
    Last Post: 01-25-2012, 01:43 AM
  2. components arrangement
    By sudhakar reddy in forum Java Applets
    Replies: 2
    Last Post: 06-03-2010, 03:58 PM
  3. Arrangement of tabs in JTabbedPane
    By swapnilnawale in forum AWT / Swing
    Replies: 0
    Last Post: 03-20-2009, 07:27 PM
  4. arrangement of components
    By masa in forum AWT / Swing
    Replies: 7
    Last Post: 12-12-2008, 10:17 AM
  5. <tr><td> arrangement in a method
    By am17mu in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 05-16-2008, 05:44 PM

Posting Permissions

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