Java Challenge (3)

java_starting.png 

Hi guys,

here I am with another Java Challenge. Looking at the following code, are you able to say where does it fail??


import java.util.ArrayList;
import java.util.List;

public class GenericsHandler {

public void insert(List list) {
list.add(new String(“42”));
}

public static void main(String[] args) {
GenericsHandler gh = new GenericsHandler();

List<Integer> list = new ArrayList<Integer>();
gh.insert(list);

System.out.println(list.size());
System.out.println(list.get(0));
}

}

Next post, I’ll come with the answer.


Fernando

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s