Java Question Error compiling

Johan Schoeman

Expert
Licensed User
Longtime User
I am missing something here. If I comment out the IF statement then the java package will compile with SLC. When the IF statement is present SLC gives the following error:
math.java:74: ';' expected
If (number == 10)
^
What am I doing wrong?


B4X:
public String ConvertToHex (int number) {
   
    int waarde;
    int newx;
    String bin;

    newx = number;
    waarde = number;
     bin = "";

    do {
      waarde = (waarde % 16);
        If (waarde == 10)                         //comment out - then compiles
          bin = bin.concat("A");                
        newx = (newx - waarde)/16;
        waarde = newx;
       } while(newx != 0);
     return bin;
}
 

stevel05

Expert
Licensed User
Longtime User
You need to wrap the block to be executed if true in {}
 

Johan Schoeman

Expert
Licensed User
Longtime User
You need to wrap the block to be executed if true in {}

Hi Steve, have tried this too/before:

If (waarde == 10)
{
bin = bin.concat("A");
}

Still won't compile. Gives me the same error
 

stevel05

Expert
Licensed User
Longtime User
The If statement should be lower case (if).

If that doesn't sort it can you post the file.
 
Top