• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need some exam links for Generics and help related to a question in Generics

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am preparing for SCJP 5.0 and finding myself very weak in Generics so much so that I sometimes feel I shouldn't have opted 5.0 exam. I tried for questions on Generics using Google, but could not find much. Can somebody provide links for the same?

Also, can someone explain why the line

Box<Integer>[] boxes = new Box<Integer>[2]

fails to compile in the code below? What is wrong in that declaration?

[B]{I]
public class New {
private String String = "Hello";

public New(String String) {
String = String;
}

public String toString() {
return String;
}

public static void main (String[] args) {
String String = "Hello World";
New instance = new New(String);
System.out.println(instance);
}
}
{/I]{/B]
 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
There is generics tutorial from sun..a pdf...give it a go..but i think K and B is more than enough..Only thing is that you need to read it 2-3 times...

Coming to your question,generics cant be applied to arrays..and thats the reason for error..

Cheers
Prashanth
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Above,

Can you give me the link to the sun's tutorial that you were mentioning??

Thanks in advance.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Found the following link usefull,
http://forum.java.sun.com/thread.jspa?forumID=316&threadID=564355

This is about Generic arrays, which are not supported in Java 1.5

- Ramu
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic