• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

array sort

 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This code thorws an exception in this line:Arrays.sort(array);

why?
 
Avishkar Nikale
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Are you sure this is the complete code?

2) Do you mean a compiler error as opposed to exception?
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the exception thrown ??
 
Damilola Okuboyejo
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
abalfazl hossein wrote:

This code thorws an exception in this line:Arrays.sort(array);

why?

--------------------------------------------
the syntax looks ok, but for the main method
guess the exception ws NoSuchMethodFoundException

TRY

import java.util.Arrays;

public class Main {

public static void main(String[] argv)
{
int i;
int array[] = {12,9,4,99,120,1,3,10};
Arrays.sort(array);

for (i = 0; i < array.length; i++)
System.out.println(array[i]);
}

}
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Damilola Okuboyejo wrote: . . . guess the exception ws NoSuchMethodFoundException . . .
Why?

As previously suggested, that looks more like a compiler error because a line was omitted. Please supply full details and the real code, abalfazl hossein
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic