-
LinkedListExamples
i want this program to print out the message "hello there stranger" but the compiler says i've completed the tool successfully but its saying i have used unchecked or unsafe operations. it says i should recompile with XLint whats this?
import java.util.*;
class LinkedListExample
{
public static void main(String args[])
{
LinkedList list = new LinkedList();
list.add(new String("Hello"));
list.add(new String("there"));
list.add(new String("stranger"));
String sentance = "";
for(int i = 0; i < list.size(); i++)
{
sentance += list.get(i) + " ";
}
System.out.println(sentance);
return;
}
}
-
-Xlint is a compiler option. Run javac with the -Xlint option.
For more details look at:
http://www.langer.camelot.de/Generic...ked%20warning?
Looks like in your code, the list.add(new String("Hello")); is the part thats causing the unchecked warning coz you r using a raw type i.e new LinkedList() and the compiler does not know/does not have enuf info to check if your LinkedList can accept strings.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks