View Single Post
  #2 (permalink)  
Old 07-31-2007, 09:16 AM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,266
hardwired is on a distinguished road
Quote:
List data = new ArrayList();
// What does get return?
System.out.println("data.get(0) = " + data.get(0).getClass().getName());
Java has no idea what is in this list. The programmer should know but the jvm cannot know. So you must cast the object that the get method returns. If there are Strings in the list then
Code:
String s = (String)list.get(0);
This is acceptable as the argument for the JTextComponent.setText method.
Reply With Quote