Results 1 to 2 of 2
  1. #1
    SrJustEasy is offline Member
    Join Date
    Dec 2016
    Rep Power

    Default if clause problem

    Hi everyone,
    i can't understand one thing of the if-else if clause. In fact, in the program i'm trying to write, i need... how can i explain this, not an else if clause, but something like a "moreover if" clause. I don't know if i have explained my problem well.

    In the program i have to make some values changes
    if the first digit of a number written by the one who runs the program equals to the first digit of the number i wrote before;
    if the second digit of a number written by the one who runs the program equals to the second digit of the number i wrote before
    etc. etc.

    how can i do this? i miss only the part with the if clauses

    Sorry for my english, i'm italian, and thank you all.
    Last edited by SrJustEasy; 12-13-2016 at 08:45 PM.

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    The Netherlands
    Rep Power

    Default Re: if clause problem

    An if statement needs a clause to be true or false, and it looks like we have it: the first digit of both inputs. I imagine it looks something like this:
    Java Code:
    boolean all_match is true
    loop for each character of the users input
       if the users character not equals my character then
            all_match is false
            break out the loop (no use continuing)
       end if
    end loop
    If the all_match variable is still true at the end of the loop, then all the digits (or characters) should be the same.

    pro tip: you can shortcut this in a few ways: if either input is empty, then a match is false to start with, if the lengths are not equal, then again there is no match possible
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013

Similar Threads

  1. DetatchedCriteria without on clause
    By TommymmoT75 in forum Hibernate
    Replies: 4
    Last Post: 08-23-2013, 05:04 PM
  2. where clause in hibernate
    By me.anchit in forum JDBC
    Replies: 0
    Last Post: 09-29-2011, 08:01 PM
  3. Need help to write where clause
    By SAR in forum New To Java
    Replies: 4
    Last Post: 07-01-2010, 09:00 AM
  4. finally clause
    By arefeh in forum New To Java
    Replies: 6
    Last Post: 01-30-2010, 09:11 PM
  5. Mysql LIKE clause problem
    By stalkerism in forum JDBC
    Replies: 1
    Last Post: 07-31-2009, 10:01 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