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.


>> REGISTER NOW TO START POSTING


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

Results 1 to 4 of 4

Thread: Java arraylist question

  1. #1
    Member
    Join Date
    Dec 2012
    Posts
    127
    My Mood
    Angelic
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Default Java arraylist question

    This is a question on my homework, can anyone help me understand what it saying ? Thanks
    "Suppose that you have an ArrayList and that it contains String objects. Which declaration of the ArrayList requires that objects retrieved using the get method be cast to Strings before calling a String method?"


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Java arraylist question

    If you must cast to a String to use it as a String, then it must be a declaration that does not return a String object "as a String"

  3. #3
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Java arraylist question

    I'm wondering...

    That question would make a lot more sense if it asked how to declare an ArrayList so that things returned by get() do not have to be cast. (angle brackets)

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Java arraylist question

    I get the impression that the multiple choice answers were left out

Similar Threads

  1. ArrayList and foreach question
    By Egde in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 17th, 2012, 06:18 PM
  2. Question about ArrayList
    By Jocko in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 2nd, 2012, 07:54 PM
  3. Arraylist input help, quick question.
    By Sarmen in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 11th, 2012, 01:37 PM
  4. ArrayList question
    By steel55677 in forum Collections and Generics
    Replies: 8
    Last Post: February 25th, 2012, 11:42 AM
  5. Please help ArrayList Question
    By SandeeBee in forum Collections and Generics
    Replies: 14
    Last Post: November 15th, 2011, 12:01 AM