Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By eRaaaa

Thread: Error: if statement

  1. #1
    Join Date
    Jul 2011
    Location
    India,Tamil Nadu
    Posts
    32
    Rep Power
    0

    Smile Error: if statement

    Hi,

    I got error in this if statement.

    int k;

    if ((k=="0") || (k=="4") || (k=="8") || (k=="16"))


    if (k.equals("1") || k.equals("2") || k.equals("3"))

    May i know how to check?

    With Regards and Respects,
    Nandhini.

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    f ((k==0) || (k==4) || (k==8) || (k==16)){

    k = int, "0" or "4" are Strings ! So you have to write 0, 4, 8 16 ....

    And k.equals is wrong because int is a primitive type and you cannot call methods on them
    nandhinianand likes this.

  3. #3
    Join Date
    Jul 2011
    Location
    India,Tamil Nadu
    Posts
    32
    Rep Power
    0

Similar Threads

  1. error while using sql update statement
    By jttslg in forum Advanced Java
    Replies: 14
    Last Post: 07-03-2011, 11:38 PM
  2. error in if statement
    By carman12 in forum New To Java
    Replies: 11
    Last Post: 12-25-2010, 02:13 AM
  3. Return statement error
    By Exothesis in forum New To Java
    Replies: 2
    Last Post: 10-13-2010, 02:56 AM
  4. Missing Return Statement Error
    By darkblue24 in forum New To Java
    Replies: 13
    Last Post: 02-16-2010, 09:22 PM
  5. Missing Return Statement error
    By anilanar in forum New To Java
    Replies: 2
    Last Post: 08-20-2009, 02:02 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
  •