Results 1 to 5 of 5
  1. #1
    mastapro is offline Member
    Join Date
    Sep 2011
    Posts
    5
    Rep Power
    0

    Default ArrayList questions

    I have a few questions if you guys don't mind.
    1) How do you store a .txt file that you would enter on the cmd line into an arraylist? (for example on the cmd line "java hello hey.txt")
    2) How do you sort words into its alphabetical letter form? (ie: hello = ehllo, pops = opps, etc.)

    Thanks.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: ArrayList questions

    Quote Originally Posted by mastapro View Post
    I have a few questions if you guys don't mind.
    1) How do you store a .txt file that you would enter on the cmd line into an arraylist? (for example on the cmd line "java hello hey.txt")
    2) How do you sort words into its alphabetical letter form? (ie: hello = ehllo, pops = opps, etc.)
    1) I don't understand this question
    2) This sounds like an interesting problem. In the interests of not cheating you out of a learning experience, why not try to solve this on your own and show us the fruits of your labors?

  3. #3
    mastapro is offline Member
    Join Date
    Sep 2011
    Posts
    5
    Rep Power
    0

    Default Re: ArrayList questions

    Thanks for responding. I figured out the first one. and about the 2nd one, i've been trying to figure it out for 2 days straight lol. i just can't seem to think of a logical way to do it...

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: ArrayList questions

    Myself, I'd convert the String to a char array, use java.util.Arrays.sort(...) method, and then convert the char array back to a String by passing it to a String constructor, 4-5 lines of code max.

  5. #5
    mastapro is offline Member
    Join Date
    Sep 2011
    Posts
    5
    Rep Power
    0

    Default Re: ArrayList questions

    thanks a lot. i'll try it and get back if i have questions.

Similar Threads

  1. Replies: 12
    Last Post: 07-07-2011, 08:49 PM
  2. copying contents of an ArrayList to another ArrayList
    By ankit1801 in forum New To Java
    Replies: 8
    Last Post: 03-27-2011, 06:07 AM
  3. sorting arraylist based on another arraylist
    By busdude in forum New To Java
    Replies: 4
    Last Post: 02-07-2011, 11:48 AM
  4. Replies: 7
    Last Post: 11-22-2010, 01:26 PM
  5. Replies: 2
    Last Post: 04-21-2008, 11:43 AM

Posting Permissions

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