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 2 of 2

Thread: String + Compare // Might be too easy for ya

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Thanked 0 Times in 0 Posts

    Exclamation String + Compare // Might be too easy for ya

    I'm a new student trying to learn java and i have been stuck on this question in the practice sheet and i cannot do it. So please help me out here.

    - Let the user Input 3 Strings "Bait, Car, Animal"
    - Then you have to sort this in alphabatic order and print it
    Animal, Car, Bait.

    I tried and i looked up ways and i found very advanced coding, like import.util.List etc

    What i learned so far is using

    while - for - do loops
    if - else if statments
    and compareTo < 0

    if that might help, please help me learn this with my simple knowledge, i would be so greateful to you

  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Thanked 619 Times in 561 Posts
    Blog Entries

    Default Re: String + Compare // Might be too easy for ya

    The import isn't that advanced, it's just saying that you want to use the Java API's List interface. However, I doubt that's what you want because that's probably not what your professor is looking for (besides, who likes to use the standard API when you can create the methods yourself?).

    All you need is a good sorting algorithm. The simplest to implement are selection sort and insertion sort. Selection sort's slightly easier to implement, but insertion sort is "more efficient" when the list is more sorted.

Similar Threads

  1. Conversion of string into integer in Java
    By JavaPF in forum Java Programming Tutorials
    Replies: 17
    Last Post: January 23rd, 2010, 09:33 AM
  2. string to double
    By wolfgar in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 13th, 2009, 10:47 PM
  3. String and int problem in swing program
    By duckman in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 21st, 2009, 02:28 AM
  4. [SOLVED] How to string a decimal number in Java?
    By Lizard in forum Loops & Control Statements
    Replies: 6
    Last Post: May 14th, 2009, 03:59 PM
  5. JAVA Image Icon and JButton resizing problem
    By antitru5t in forum AWT / Java Swing
    Replies: 1
    Last Post: March 13th, 2009, 04:39 AM