Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
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.

 

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


public class Icompatobletype {

    public static void main(String[] args) {

        int rollnum = 76;
        char sec;
        if (rollnum = 90) {
            sec = 'A';
        else {
            sec = 'B';
        }
        System.out.println("Section with this rollno is:  = " + sec);
    }
}

Output

Compiling 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) {
error
BUILD FAILED (total time: seconds)

To resolve this error give if (rollnum = =90)instead of if (rollnum = 90)

Download code

                         

» View all related tutorials
Related Tags: java c memory time application object io runtime free method get order return this sso ai app with to run

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

Hi
Any body help I am getting Incompatitable error while wirrting code in eclipse

MyClass mc = new MyClass();
ArrayList exam = mc .exMethod(fName, lName, sRank);

actually the above method retuns string array but I want use above code

Pls suggest how to avoid this error
is there any exception handling or if any

thanks
kumar

Posted by Kumar on Friday, 11.14.08 @ 07:17am | #81677

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.