DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2005
    Posts
    14

    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;
    }
    }

  2. #2
    Join Date
    Aug 2005
    Posts
    1
    -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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


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


Sponsored Links