LinkedListExamples


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: LinkedListExamples

  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.

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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center