Results 1 to 4 of 4
- 07-11-2008, 02:55 PM #1
Member
- Join Date
- Jun 2008
- Posts
- 85
- Rep Power
- 0
compilation error(version problem?)
hi i tried the following example
i get this following compilation errorJava Code:import java.util.*; public class Program { public static void main(String[] args) { // Create an ArrayList containing a simple sentence. ArrayList arrList = new ArrayList(); arrList.add(new String("Today")); arrList.add(new String("is")); arrList.add(new String("Thursday")); // Change the day to Friday. arrList.set(2, new String("Friday")); Iterator iter = arrList.iterator(); while (iter.hasNext()) { System.out.print(iter.next() + " "); } } }
C:\world>javac Program.java
Note: Program.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
i use jdk1.5.0_15 is this the problem? i think the problem is using .add() method ...am i wrong?
- 07-11-2008, 03:51 PM #2
Generics
Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
- 07-11-2008, 04:26 PM #3
Have you tried what the compiler recommends? You will get more detailed line-by-line warnings showing where the problems are in your code.Recompile with -Xlint:unchecked for details.
To remove these warnings, you need to use Generics. They allow the compiler to type check your use of methods that previously took type Object and required the programmer to typecast objects passed into and out of Collection items for example. By using Generics, you won't have to type cast and the compiler will check that your objects are the correct type.
- 07-11-2008, 04:31 PM #4
Member
- Join Date
- Jun 2008
- Posts
- 85
- Rep Power
- 0
Similar Threads
-
Unresolved compilation problem
By mew in forum New To JavaReplies: 2Last Post: 12-30-2007, 07:17 PM -
Unresolved compilation problem
By mew in forum New To JavaReplies: 3Last Post: 12-11-2007, 11:49 AM -
Error in version of JDK and compatibility of JDK issues
By Unni in forum EclipseReplies: 1Last Post: 08-09-2007, 07:32 PM -
compilation error with Jcreator
By Heather in forum JCreatorReplies: 2Last Post: 06-30-2007, 04:12 PM -
compilation issue
By orchid in forum EclipseReplies: 2Last Post: 04-20-2007, 12:51 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks