Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error

Status
Not open for further replies.

YerMom

Programmer
Oct 3, 2006
127
0
0
US
I'm trying to create an object of a class that has the following declaration and constructor:

Code:
public class SomeClass<T> 
{
  protected T value = null;

  public SomeClass(T value)
  {
    this.value = value;
  }
  ...
}

I'm using the following to create the object:
Code:
SomeClass sc = new SomeClass(0);

However, this give me the following compile warning:
Code:
warning: [unchecked] unchecked call to SomeClass(T) as a member of the raw type com.myCompany.myPackage.SomeClass

Note that I cannot change anything about SomeClass. Is it possible to eliminate the compiler warning by changing the way I create the object?

I've seen numerous postings on numerous websites about this warning and I know that it is related to generics, but all the solutions say to modify the class. But as I mentioned, I cannot change the class.

I'm using jdk 1.6.0_03

Thanks.



 
Thanks, Stefan -- works fine.

Now that I know the answer it makes sense...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top