Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Generics and Sort

Reply
Thread Tools

Generics and Sort

 
 
Roedy Green
Guest
Posts: n/a
 
      07-12-2005
I write lines like this:

Arrays.sort( anArray );
Collection.sort( anArrayList );
Collection.sort( anArrayList, new DescendingNumerically() );


sometimes the compiler likes them and other times it does not. The
mystery is solved. Though it complains there, the problem is miles
away, and not at the declarations either:

ArrayList anArraylist = new ArrayList<Entry>(200);

The problem is in the declaration of Entry.

It must say implements Comparable<Entry> not just implements
Comparable. You'd think somehow the compiler would know it had to be
comparing Entry objects but it doesn't.

In a similar way Eclipse often complains that some symbol is undefined
when it really means the import statement for type corresponding to
that symbol is missing.

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/...s_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
Reply With Quote
 
 
 
 
Tim Miller
Guest
Posts: n/a
 
      07-12-2005
Roedy Green wrote:
> In a similar way Eclipse often complains that some symbol is undefined
> when it really means the import statement for type corresponding to
> that symbol is missing.
>

Eclipse could not possibly tell the difference. All it sees is a
name that is not in the typing environment. For example, if you
had misspelt an identifier, it COULD complain that you haven't
imported that class in which the name is defined, but that could
be misleading because there may be no such package. As far as
eclipse is concerned, the name is undefined because it is not in
the "current" environment.
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      07-12-2005
On Tue, 12 Jul 2005 10:00:06 +0100, Tim Miller <(E-Mail Removed)>
wrote or quoted :

>Eclipse could not possibly tell the difference. All it sees is a
>name that is not in the typing environment. For example, if you
>had misspelt an identifier, it COULD complain that you haven't
>imported that class in which the name is defined, but that could
>be misleading because there may be no such package. As far as
>eclipse is concerned, the name is undefined because it is not in
>the "current" environment.


the error message is misleading, "symbol" would make you think there
is something wrong with the name you are defining, the thing being
added to the symbol table. The error would be clearer if they said
Class X is undefined or simply X is undefined.

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/...s_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
Reply With Quote
 
Thomas G. Marshall
Guest
Posts: n/a
 
      07-12-2005
Roedy Green coughed up:
> On Tue, 12 Jul 2005 10:00:06 +0100, Tim Miller <(E-Mail Removed)>
> wrote or quoted :
>
>> Eclipse could not possibly tell the difference. All it sees is a
>> name that is not in the typing environment. For example, if you
>> had misspelt an identifier, it COULD complain that you haven't
>> imported that class in which the name is defined, but that could
>> be misleading because there may be no such package. As far as
>> eclipse is concerned, the name is undefined because it is not in
>> the "current" environment.

>
> the error message is misleading, "symbol" would make you think there
> is something wrong with the name you are defining, the thing being
> added to the symbol table. The error would be clearer if they said
> Class X is undefined or simply X is undefined.



This is hardly cause for a thread, but you've got my curiosity a-brewing.
And I'm trying hard to see what you mean. "symbol" is just what it is, from
"symbol table" as you pointed out. And eclipse has no way of knowning what
is meant by it when there is no import for it, so it is undefined.

{shrug with palms face up} Am I missing something here?


--
Puzzle: You are given a deck of cards all face down
except for 10 cards mixed in which are face up.
If you are in a pitch black room, how do you divide
the deck into two piles (may be uneven) that each
contain the same number of face-up cards?
Answer (rot13): Sebz naljurer va gur qrpx, qrny bhg
gra pneqf naq syvc gurz bire.


 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      07-14-2005
On Tue, 12 Jul 2005 23:54:55 GMT, "Thomas G. Marshall"
<(E-Mail Removed). com> wrote or quoted
:

>{shrug with palms face up} Am I missing something here?


compare Jikes, Javac and Eclipse error messages for usefulness in
figuring out the problem. Eclipse is by far the worst. It makes up
for it by squiggling as you pointing you to the right place the
keystroke you make the error. You know the problem had to with what
you just typed. Ordinary compilers don't give yo that clue.


It is sort of like you paused after every keystroke to do a compile,
but there is no delay.

I found the way to work with Eclipse is never to let there be more
than a handful of outstanding problems. It works ever so much better
on an almost perfect program.

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/...s_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
generics depending on generics Soul VHDL 0 02-02-2009 09:14 AM
Selection sort and bubble sort lovecreatesbea...@gmail.com C Programming 22 10-19-2007 06:16 AM
Can't convert a generics list of objects into a generics list ofinterfaces Juergen Berchtel Java 1 05-20-2005 02:07 PM
How would I use qsort to sort a struct with a char* member and a long member - I want to sort in order of the long member Angus Comber C Programming 7 02-05-2004 06:41 PM
Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. Navin ASP General 1 09-09-2003 07:16 AM



Advertisments