Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: How to write this without

  1. #1
    Member Scotty's Avatar
    Join Date
    Oct 2010
    My Mood
    Thanked 0 Times in 0 Posts

    Default How to write this without

    HashSet<String> Cats = map.getAll();
    int numCats = Cats.size()

    I have tried in so many different ways, but I always get an unchecked exception. getAll generates a HashSet.

    int numCats = map.getAll.size();
    HashSet<String> Cats = new HashSet <String>();
    Cats = map.getAll(); or Cats.add(map.getAll());

    no matter what I do I get unchecked

  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    My Mood
    Thanked 167 Times in 158 Posts

    Default Re: How to write this without

    I don't understand the question. If you are asking how to do it without the Generics then I counter with: Why do you want to do that?

    If you get the "unchecked exception" then it is only a warning. your code will still compile and run. Or you can compile with the "suppress warnings" option.

  3. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Washington, DC
    My Mood
    Thanked 632 Times in 540 Posts

    Default Re: How to write this without

    If you want help with code, you'll have to post an SSCCE demonstrating what you're actually doing. Otherwise we're just guessing.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. [SOLVED] Write an xml dom to a xml file
    By Kakashi in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: March 2nd, 2011, 02:30 PM
  2. How to write server?
    By snytkine in forum Java Networking
    Replies: 4
    Last Post: October 22nd, 2010, 02:25 PM
  3. how can i write this program
    By lavudyagopi27 in forum Java Theory & Questions
    Replies: 2
    Last Post: September 17th, 2010, 08:11 AM
  4. [SOLVED] How to write to an application
    By straw in forum Java Theory & Questions
    Replies: 4
    Last Post: June 19th, 2010, 10:17 AM
  5. How to write above a JPanel
    By bruno88 in forum AWT / Java Swing
    Replies: 4
    Last Post: June 23rd, 2009, 06:16 PM