Results 1 to 2 of 2
  1. #1
    vineet9872 is offline Member
    Join Date
    Feb 2014
    Posts
    1
    Rep Power
    0

    Default Geeting error n string sorting

    I am getting error
    Exception in thread "main" java.lang.Error: Unresolved compilation problem:

    at pack1.Run3.main(Run3.java:6)


    package pack1;

    public class Run3
    {

    public static void main(String[] args)
    {
    int[] a = {10,1,14,7,3};
    int temp;
    for(int i=1;i<=a.length-1;i++)
    {
    for(int j=0;j<=a.length-2;i++)
    {
    if(a[j]>a[j+1])
    {
    temp = a[j+1];
    a[j+1] = a[j];
    a[j] = temp;
    }
    }
    }
    }

    }

    }

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,646
    Rep Power
    5

    Default Re: Geeting error n string sorting

    Properly formatting your code will help you find errors like this:

    Java Code:
    package pack1;
     
    public class Run3 
    {
     
        public static void main(String[] args) 
        {
            int[] a = {10,1,14,7,3};
            int temp;
            for(int i=1;i<=a.length-1;i++)
            {
                for(int j=0;j<=a.length-2;i++)
                {
                    if(a[j]>a[j+1])
                    {
                        temp = a[j+1];
                        a[j+1] = a[j];
                        a[j] = temp;
                        } //<-----------------
                    }
                }
            }
     
        }
     
    }
    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

Similar Threads

  1. Sorting ArrayList consisting of String Arrays.
    By Problemer in forum New To Java
    Replies: 2
    Last Post: 11-13-2012, 05:04 PM
  2. Help - (Sorting characters in a string)
    By DanPe in forum New To Java
    Replies: 1
    Last Post: 05-11-2012, 11:57 PM
  3. Sorting in string
    By BlueBird in forum New To Java
    Replies: 8
    Last Post: 02-28-2012, 10:10 AM
  4. Scanner, while loop and sorting arrays/string?
    By RSYR in forum New To Java
    Replies: 10
    Last Post: 04-20-2011, 06:13 PM
  5. Sorting string Array Values
    By Zerpol in forum New To Java
    Replies: 1
    Last Post: 01-14-2011, 07:08 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
  •