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: Very Confused Over Java Problem

  1. #1
    Junior Member
    Join Date
    Jul 2017
    Thanked 0 Times in 0 Posts

    Question Very Confused Over Java Problem

    Hello! So I've been completing some java coursework for a class next year but I've ran into a problem that I have no idea how to code for. I usually blow through these problems but I'm stunted at this. Don't even know where to start. I re-read the section on conditionals and looping but nowhere does it touch on string length or anything. Any help would be appreciated. The question states:


    Suppose s, t, and w are strings that have already been created inside main. Write a statement or statements, to be added to main, that will determine if the lengths of the three strings are in order by length, smallest to largest. That is, your code should determine if s is strictly shorter than t, and if t is strictly shorter than w. If these conditions hold your code should print (the boolean value) true. If not, your code should print false. (Strictly means: no ties)

    Example: if s, t, and w are "cat", "Hats", and "skies" your code should print true - their lengths are 3-4-5;
    but if s, t, and w are "cats" "shirt", and "trust", then print false - their lengths are 4-5-5

    Enter your code in the box below


    I would assume it has something to do with Booleans or if/then/else statements, but i'm still very confused! I mean, how would I even start to code something like this?! My book isn't telling me anything.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    On vacation
    Thanked 2,425 Times in 2,378 Posts

    Default Re: Very Confused Over Java Problem

    determine if the lengths of the three strings are in order by length
    Sounds like some if statements would be used.

    What problems are you having? Post your code and ask some questions about it.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. java question confused on:
    By rickster31 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 16th, 2012, 09:06 AM
  2. Arraylist pass/fail values problem/confused.
    By BITmixit in forum Collections and Generics
    Replies: 3
    Last Post: February 25th, 2012, 09:58 AM
  3. confused on what this problem is asking for (bitwise operators)
    By mmholdford in forum Java Theory & Questions
    Replies: 3
    Last Post: February 9th, 2012, 06:52 AM
  4. Newbie: seem confused with Java
    By boyscout in forum Java Theory & Questions
    Replies: 1
    Last Post: April 8th, 2011, 09:12 AM
  5. [SOLVED] Java beginner is confused....
    By truebluecougarman in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 27th, 2011, 08:50 AM

Tags for this Thread