Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

Is this compiler warning impossible to get rid of?

Thread view: 
Vittorix - 16 Nov 2006 23:23 GMT
Hi all,

I'm talking about of the following warning:
 "myClass.java uses unchecked or unsafe operations.
  Note: Recompile with -Xlint:unchecked for details."

Usually when this warning occours for a LinkedList or for other linear
structures, is sufficient to declare the type, e.g.:
  LinkedList<Integer> list = new LinkedList<Integer>();
and the warning disappears.

but in my case, I have an array of Java's LinkedLists, and I didn't find the
way to get rid of the warning!
Does anyone have an idea?

My declaration (the structure is a separated chaining hash which works
well):

class   HashSeparateChaining
{
   protected int   hashSize;
   protected LinkedList[] hash;

   public HashSeparateChaining (int size)
   {
       hashSize = size;
       inCount = 0;
       outCount = 0;
       hash = new LinkedList[hashSize];
       for(int i = 0; i < hashSize; i++)
           hash[i] = new LinkedList();
   }

   // rest of the class
   // [.......................]
}

Thanks in advance.

Signature

ciao
Vittorix

Daniel Pitts - 17 Nov 2006 00:23 GMT
> Hi all,
>
[quoted text clipped - 38 lines]
> ciao
> Vittorix

What about having an "ArrayList<LinkedList<Type>> hash = new
ArrayList<LinkedList<Type>>()" instead of managing an array yourself?

There is generally no way to handle generics and arrays together the
way you're trying to.
Vittorix - 17 Nov 2006 00:32 GMT
"Daniel Pitts"

> What about having an "ArrayList<LinkedList<Type>> hash = new
> ArrayList<LinkedList<Type>>()" instead of managing an array yourself?

yeah, but I wanted to handle things by myself, more efficently

> There is generally no way to handle generics and arrays together the
> way you're trying to.

thanks, so this is the conclusion.

Signature

ciao
Vittorix

Daniel Pitts - 17 Nov 2006 01:34 GMT
> "Daniel Pitts"
>
[quoted text clipped - 11 lines]
> ciao
> Vittorix

A little advice, Don't handling things yourself "more efficently"
unless you find out (as in, use a profiler) that you need it. Its a
bigger headache than you need.

You're little class might be better replaced by HashMap or HashSet,
depending on what its doing.  I would only try to find/create a
different collection type of class if there aren't any standard ones
that work "well enough".
Vittorix - 17 Nov 2006 16:16 GMT
"Daniel Pitts"

>> yeah, but I wanted to handle things by myself, more efficently

> A little advice, Don't handling things yourself "more efficently"
> unless you find out (as in, use a profiler) that you need it. Its a
> bigger headache than you need.

ok :)

> You're little class might be better replaced by HashMap or HashSet,
> depending on what its doing.  I would only try to find/create a
> different collection type of class if there aren't any standard ones
> that work "well enough".

you are right, thanks

Signature

ciao
Vittorix

Vittorix - 17 Nov 2006 16:17 GMT
"Vittorix"

> I'm talking about of the following warning:
>  "myClass.java uses unchecked or unsafe operations.
[quoted text clipped - 8 lines]
> the
> way to get rid of the warning!

I found this way to suppress the warning. it is not like fixing it, but it
works:
@SuppressWarnings("unchecked")

Signature

ciao
Vittorix



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.