Java IF statments and == opperator

Dude, why the crap is the statment in the if being reached??? Is this not correct syntax in java to compare to ints?

if(1==10);
{ //this is returning!?!?! 1 dosen't equal 10?
return columnCounter;

}

How is 1 equal to 10?

Comments

  • : Dude, why the crap is the statment in the if being reached??? Is this not correct syntax in java to compare to ints?
    :
    : if(1==10);
    : { //this is returning!?!?! 1 dosen't equal 10?
    : return columnCounter;
    :
    : }
    :
    : How is 1 equal to 10?
    :

    1 is not equal to 10, you have an error in your code. The ; at the end of the if statement does not belong there. With the semicolon at the end of the if( or an else, while, or for), the block after it is no longer a part of the if statement. But, that does not mean that 1==10 was evaluated as true.
  • thanks, i didn't see the ";" there. I'm so dumb.
  • [b][red]This message was edited by Vilanye at 2005-8-11 14:1:1[/red][/b][hr]
    : thanks, i didn't see the ";" there. I'm so dumb.
    :


    Not dumb, it is something everyone does from time to time, no matter how good a programmer they are.

    That is what makes programming so fun, you never stop making boneheaded mistakes. :)


  • : if(1==10);
    : { //this is returning!?!?! 1 dosen't equal 10?
    : return columnCounter;
    :
    : }
    :
    : How is 1 equal to 10?


    :-) VARIABLE! [b]if (i == 4)...[/b] See really example

    public void Field_Fill()
    { //See Java documentation for beginners
    // [b]http://www.geocities.com/aboutsoft/[/b]

    for (int i=0; i<8; i++)
    {
    Color_Chars(i); //Write the nominal values and the attributes of the cell down to Label56
    cs = label56.getText(); //Write the nominal value from Label56 to the variable cs
    if ([b]i == 0[/b]) label7.setText(cs);
    if (i == 1) label8.setText(cs);
    if (i == 2) label9.setText(cs);
    if (i == 3) label10.setText(cs);
    if (i == 4) label11.setText(cs);
    if (i == 5) label12.setText(cs);
    if (i == 6) label13.setText(cs);
    if (i == 7) label14.setText(cs);

    dg = label56.getBackColor(); //Write BackColor from Label56 to the variable dg
    if (i == 0) label7.setBackColor(dg);
    if (i == 1) label8.setBackColor(dg);
    if (i == 2) label9.setBackColor(dg);
    if (i == 3) label10.setBackColor(dg);
    if (i == 4) label11.setBackColor(dg);
    if (i == 5) label12.setBackColor(dg);
    if (i == 6) label13.setBackColor(dg);
    if (i == 7) label14.setBackColor(dg);

    dk = label56.getForeColor(); //Write ForeColor from Label56 to the variable dk
    if (i == 0) label7.setForeColor(dk);
    if (i == 1) label8.setForeColor(dk);
    if (i == 2) label9.setForeColor(dk);
    if (i == 3) label10.setForeColor(dk);
    if (i == 4) label11.setForeColor(dk);
    if (i == 5) label12.setForeColor(dk);
    if (i == 6) label13.setForeColor(dk);
    if (i == 7) label14.setForeColor(dk);
    cs = "";
    }
    }




    VB Documentation http://www.geocities.com/oflameron/

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories