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.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: what's wrong with this statement

  1. #1
    Member
    Join Date
    Aug 2013
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default what's wrong with this statement

    When I try to use the following as the beginning of any statement, I get an error:

     
    if (s[i] % 10) > 3)

    How would I go about doing this?



  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,592
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: what's wrong with this statement

    I get an error
    Please copy the full text of the error message and paste it here. It has important info about the error.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Oct 2013
    Posts
    18
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: what's wrong with this statement

    Quote Originally Posted by ghostheadx View Post
    When I try to use the following as the beginning of any statement, I get an error:

     
    if (s[i] % 10) > 3)

    How would I go about doing this?

    One open bracket is missing.
    try:
    if (s[i] % 10 > 3)

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,592
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: what's wrong with this statement

    @aba muhammad
    Removing brackets makes the code harder to read. Properly placed ()s make the code easier to understand and prevents confusion on operator precedents.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Member
    Join Date
    Aug 2013
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: what's wrong with this statement

    I knew that as like a syntax error, but I mean it returns a cannot find symbol error, even when I fix that. Although, I think norm is possibly right.

  6. #6
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,295
    My Mood
    Mellow
    Thanks
    193
    Thanked 669 Times in 656 Posts

    Default Re: what's wrong with this statement

    aba muhammad's point is that there are 2 close parens to only one open paren in the original. There's a paren mismatch. Take one away as aba muhammad suggested or add one to make it look better, but fix the mismatch.

  7. #7
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: what's wrong with this statement

    Quote Originally Posted by ghostheadx View Post
    it returns a cannot find symbol error.
    Then the array s is not in scope.
    Improving the world one idiot at a time!

Similar Threads

  1. whats wrong with this if and else statement . how can i solve it
    By rafina8527 in forum Loops & Control Statements
    Replies: 1
    Last Post: February 19th, 2012, 04:03 AM
  2. [SOLVED] What's Wrong With My Code: If Statement.
    By Java Programmer in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 9th, 2012, 07:31 PM
  3. What is wrong with my if/else statement?
    By CSUTD in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 24th, 2011, 02:34 PM
  4. whats wrong with my if statement
    By semicolon in forum What's Wrong With My Code?
    Replies: 5
    Last Post: May 23rd, 2011, 04:28 PM
  5. what is wrong with my return statement??????
    By amr in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 13th, 2010, 06:55 PM

Tags for this Thread