JAVA compile error -- I think


#1

FAILURE: Build failed with an exception.

What went wrong:
Execution failed for task ‘:app:compileDebugJavaWithJavac’.
Compilation failed; see the compiler error output for details.


#2

This error states that the problem was found on line 13 and that a ‘;’ was expected but not found.

Another common syntax error is misspelling the name of a variable or method. For example, if you wrote printline rather than println in the above code, you would see the following upon compiling:

HelloWorld.java:13: cannot resolve symbol
symbol : method printline (java.lang.String)
location: class com.otherwise.jurtle.Console
Console.printline(“Hello world”);
Even though your program may be syntactically correct, the compiler may discover a semantic error (i.e., an error in usage). One example would be if your program tried to use a variable that has never had an initial value set. For example, if you had the following code snippet:

public void runTurtle()
{
int j;
Console.println(j);
}

The compiler would complain:

Test.java:12: variable j might not have been initialized
Console.println(j);

For example, in the ASimpleSquare example file there is a for loop. If the keyword for is accidentally mistyped as in:

    fo ( int i = 0; i < 4; i++ )
    {
        forward( 60 );
        right( 90 );
    }

The compiler will generate something like:

ASimpleSquare.java:24: ‘.class’ expected
fo ( int i = 0; i < 4; i++ )
^
ASimpleSquare.java:24: ‘)’ expected
fo ( int i = 0; i < 4; i++ )
^
ASimpleSquare.java:24: not a statement
fo ( int i = 0; i < 4; i++ )
^
ASimpleSquare.java:24: ‘;’ expected
fo ( int i = 0; i < 4; i++ )
^
ASimpleSquare.java:24: unexpected type
required: value
found : class
fo ( int i = 0; i < 4; i++ )
^
ASimpleSquare.java:24: cannot resolve symbol
symbol : variable i
location: class ASimpleSquare
fo ( int i = 0; i < 4; i++ )
^

Ethan Stark
https://www.clouddesktoponline.com/


#3

Nice, thanks
I think you are totally right in your choise