• Post Reply Bookmark Topic Watch Topic
  • New Topic

import  RSS feed

 
blossom belle
Ranch Hand
Posts: 145
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if i use import java.util.*;

and then use the Arrays class to call the sort method , it shows cannot find method sort

may i know why
with the wildcard, the whole Arrays class is imported right
 
Stephan van Hulst
Saloon Keeper
Posts: 7983
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two things I can think of. You're either passing an argument of an incompatible type, or you have hidden the Arrays class by adding a class of the same name to your package.

Can you show us the exact stack trace?
 
blossom belle
Ranch Hand
Posts: 145
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

line 5 shows a compile error.
 
blossom belle
Ranch Hand
Posts: 145
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but if i use import java.util.Arrays; it works

whats wrong with the * ?
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
line 5 shows a compile error.

Can you copy/paste exact error message after you tried to compile the code snippet you showed.

For me it does work as expected. It sorts out an array.
 
Stephan van Hulst
Saloon Keeper
Posts: 7983
143
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty sure you added a class named Arrays to your package. Don't give classes the same name as those that already exist in the widely used packages of the standard API.
 
blossom belle
Ranch Hand
Posts: 145
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh yes i just found a class that has the name Arrays ! thanks ! 
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!