Java error incompatible types
Java Error incompatible types occurred when a compiler found a variable and expression whose data type is not compatible to perform an operation on them.
Understand with an Example
In this Tutorial we want to describe you a code that help you in understanding the java error incompatible type. For this we have a class name Incompatobletype.Inside the main method we declare a variable name roll num and sec int and char data type. Checklist condition is used to evaluate the expression. The assignment operator = is used to show you an incompatible type error in java rather than using = = in assignment operator. The Java Compiler show an error in the assignment operator printed by System.out.println.
Incompatitabletype.java
|
Output
Compiling 1 source file to /home/girish/NetBeansProjects/errors/build/classes /home/girish/NetBeansProjects/errors/src/Icompatobletype.java:8: incompatible types found : int required: boolean if (rollnum = 90) { 1 error BUILD FAILED (total time: 0 seconds) |
To resolve this error give if (rollnum = =90)instead of if (rollnum = 90)
Download code