Results 1 to 6 of 6
  1. #1
    echo33 is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Post alphabatize words without using arryas???

    i need to read a file and sort the words within the file into aplhabitical order, only problem i cant use arrays.

    help???

  2. #2
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    6

    Default

    how about a binary search tree...

  3. #3
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    6

    Default

    ArrayList? It's not "technically" an array.
    Liberty has never come from the government.
    Liberty has always come from the subjects of government.
    The history of liberty is the history of resistance.
    The history of liberty is a history of the limitation of governmental power, not the increase of it.

  4. #4
    logicbug's Avatar
    logicbug is offline Member
    Join Date
    Jan 2009
    Location
    The Great White North, eh?
    Posts
    76
    Rep Power
    0

    Default

    Quote Originally Posted by xcallmejudasx View Post
    ArrayList? It's not "technically" an array.
    you could read String objects and put them in a Vector as well....

    If you wanted to be a smartass about it your could create your own class called notAnArray that extends Array and use it instead!

    Sorry, I had a couple beer at lunch and am feeling kind of cheeky =P

  5. #5
    Xhile is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Default lol.

    how bullshit is it that we cant use arrays or linkedlists.

    shit would be so much easier ye?

  6. #6
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    828
    Rep Power
    6

    Default

    Check wheteher this code helps you are not.
    import java.io.File;
    import java.util.Scanner;
    import java.util.*;

    /*sample.txt content
    Ramya
    Anjali
    Harthi
    */
    /* Output
    Anjali
    Harthi
    Ramya
    */
    class Sample
    {
    public static void main(String args[])
    {
    try
    {
    Scanner scannerObject = new Scanner(new File("sample.txt"));

    TreeSet ts = new TreeSet();
    while(scannerObject.hasNextLine())
    {
    ts.add(scannerObject.nextLine());
    }//while

    Iterator it1 =ts.iterator();
    while(it1.hasNext())
    {
    Object o1 = it1.next();
    System.out.println(o1);
    }

    }catch(Exception ex)
    {
    System.out.println(ex);
    }

    }
    }

Similar Threads

  1. Money to Words
    By javanewbie in forum New To Java
    Replies: 2
    Last Post: 06-30-2008, 04:27 AM
  2. Scrambling Words
    By Shadow22202 in forum New To Java
    Replies: 9
    Last Post: 04-30-2008, 03:51 AM
  3. help w words
    By Gilgamesh in forum New To Java
    Replies: 5
    Last Post: 11-21-2007, 06:15 PM
  4. Analyze a string of words
    By zoe in forum Advanced Java
    Replies: 2
    Last Post: 07-26-2007, 10:01 AM
  5. Aspose.Words for Java - 2.1.0.0
    By levent in forum Java Software
    Replies: 0
    Last Post: 05-24-2007, 10:08 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
  •