Generics Problem
Hi,
I tried the following code(from an example)
public class Test {
private Integer i = new Integer(4);
private String s = new String("FFFF");
HashMap<Integer, String> hash = new HashMap<Integer, String>();
hash.put(i , s);
}
The has.put(i,s) gives the following errors:
"Cannot resolve Symbol put" and "Unknown class" for i and s.
I followed the installation procedures in the Help for Generics. Also Pallada happily does the auto-complete for the new HashMap (as per the test in the Help file).
Any suggestions will be much appreciated.
Also...just curious... but why, when using the jdk 1.5 beta, do we still need the jsr based collection.jar and gjc-rt.jar. Shouldn't these be in the 1.5 JDK?
Thanks
Trev...
Please sign in to leave a comment.
Hello!
>
>
>
It becouse you should do thi within method body call:
public class Test {
private Integer i = new Integer(4);
private String s = new String("FFFF");
HashMap<Integer, String> hash = new HashMap<Integer, String>();
public void foo() {
hash.put(i , s);
}
}
or
public class Test {
private Integer i = new Integer(4);
private String s = new String("FFFF");
HashMap<Integer, String> hash = new HashMap<Integer, String>();
{
hash.put(i , s);
}
}
Thanks!
oops!....
thanks :)
Trev...
By the way you shouldn't be using implementation classes as types. :) At least, not for collections classes. This is considered better form:
>
Shouldn't these be in the 1.5 JDK?
>
You don't need collect.jar and gjc-rt.jar when using jdk 1.5. Just "-source 1.5" compiler flag
--
Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"
>> Also...just curious... but why, when using the jdk 1.5 beta, do we
>> still need the jsr based collection.jar and gjc-rt.jar.
>>
I get an error message sating cannot locate collect.jar in my Idea lib folder. Where should I put this compiler flag?
-- Posted by JetBrains OmniaMea
You need to turn off the "use generics-enabled compiler" checkbox. It shouldn't be looking for collect.jar.
Thanks
That got it!
scott
-- Posted by JetBrains OmniaMea
We'll fix this in Pallada - it will honor the check only for JDK 1.4 versions.
--
Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"
Hello Eugene,
So, you have two ways to use Generics -- use JDK 1.4 plus configuring the "Setup JSR014 Implementatin" wizard with downloadable Generics goodies -- AND -- simply using JDK 1.5 Beta (turning off 'use generics compiler' under compiler settings)?
David
"David Stennett" <david@nospamthankyou.com> wrote in message
news:c4c4rd$1hv$1@is.intellij.net...
>
>
"Setup JSR014 Implementatin" wizard with downloadable Generics goodies --
AND -- simply using JDK 1.5 Beta (turning off 'use generics compiler' under
compiler settings)?
...and the second way you have to pass -source 1.5 to jdk1.5 javac.
P.S. Sorry for being wrong Eugene=)