Results 1 to 4 of 4
  1. #1
    artemff is offline Member
    Join Date
    Dec 2009
    Posts
    41
    Rep Power
    0

    Question What class functions like list of strings?

    What class functions like list of strings? Enumeration is not good because it is not possible to access to string with index?? Thanks

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,368
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by artemff View Post
    What class functions like list of strings? Enumeration is not good because it is not possible to access to string with index?? Thanks
    A List<String> can do the job, as in:

    Java Code:
    // a list of Strings
    List<String> yourList= new ArrayList<String>();
    kind regards,

    Jos

  3. #3
    artemff is offline Member
    Join Date
    Dec 2009
    Posts
    41
    Rep Power
    0

    Question

    JosAH, Thanks..One question, is it needed addition <String> set after every method?
    myList.size<String>() or myList.size()...

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,368
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by artemff View Post
    JosAH, Thanks..One question, is it needed addition <String> set after every method?
    myList.size<String>() or myList.size()...
    No there is no need to do that; after you have declared the type of the list (List<String>) and created one the compiler knows that its elements shall all have type String and flags every attempt to do otherwise as an exception. So, basically you can use the 'raw' methods whereever you want.

    kind regards,

    Jos

Similar Threads

  1. Need help using the Linked List class
    By wlc in forum New To Java
    Replies: 1
    Last Post: 08-13-2009, 03:38 AM
  2. Creating a Defined Class with Member Functions
    By New2Java in forum New To Java
    Replies: 6
    Last Post: 08-05-2009, 09:05 PM
  3. have "regular" functions - with no class
    By itaipee in forum New To Java
    Replies: 2
    Last Post: 01-29-2009, 03:12 PM
  4. Replies: 0
    Last Post: 11-15-2008, 10:09 PM
  5. Accessing list out another class
    By Preethi in forum New To Java
    Replies: 23
    Last Post: 10-26-2008, 02:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •