Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Paul Clapham
Tim Cooke
Devaka Cooray
Sheriffs:
Liutauras Vilda
paul wheaton
Rob Spoor
Saloon Keepers:
Tim Moores
Stephan van Hulst
Tim Holloway
Piet Souris
Mikalai Zaikin
Bartenders:
Carey Brown
Roland Mueller
Forum:
Programmer Certification (OCPJP)
Generics Question
Chandana Garlapati
Ranch Hand
Posts: 97
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
This question is from javabeat mock
test
.
My question is Non generic ref. type + Generic instant----> compiles without warning..
But why the above code compiles with warning???
import java.util.*; class TestSamp1 { public static void main(String [] args) { Set vals = new TreeSet<String>(); vals.add("one"); vals.add("1"); vals.add("two"); System.out.println(vals); } }
Marcin Kwiatkowski
Ranch Hand
Posts: 32
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You're trying to add element to raw type. It doesn't matter that you've instantiated 'vals' with parametrized type as long as reference type is not parametrized.
Chandana Garlapati
Ranch Hand
Posts: 97
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
got it..
Thanks Marcin Kwiatkowski
I'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
non-generic collection always compiles with warning ?
Generics Question
Generics
Mock Questions on Generics
What should be the o/p?
More...