Results 1 to 3 of 3
  1. #1
    Haske2r is offline Member
    Join Date
    Jan 2010
    Posts
    1
    Rep Power
    0

    Default Incompatible operand types int and double[][]

    Hello

    I just started java and try to do a programm wich is able to give me a fast solution of the Gaus System. (If anyone knows ;-) )

    But I got a problem:

    import java.util.Scanner;
    public class Info {

    /**
    * @param args
    */
    public static void main(String[] args) {

    int a;
    double b [][] = new double [4][4];
    int c;

    Scanner in = new Scanner(System.in);

    System.out.println("Hello, first equation please:");
    for(a=0 ; a< b.length ;a++){
    System.out.println("Number:" + (a+1) + "");
    if (a==b) Incompatible operand types int and double[][]
    a= 0;


    for(c=0; c<b.length;c++)

    b [a][c] = in.nextDouble();

    }
    System.out.println("The first equation:");
    System.out.println( b[0] +" x1 " +b[1]+" x2 "+ b[3]+ " x3 = " +b[3]);

    }

    }
    If you are able to help me I would be verry happy :)

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,784
    Blog Entries
    7
    Rep Power
    21

    Default

    Variable 'a' has type int and variable 'b' has type double[][]; how can you compare the two for equality? Answer: you can't and that's why the compiler is whining at you.

    kind regards,

    Jos

  3. #3
    [RaIdEn] is offline Senior Member
    Join Date
    Oct 2009
    Location
    California,US
    Posts
    201
    Rep Power
    6

    Default

    the best thing you can do is make a cast and into quality of a specific element in the array.

    a==(int) b[1][2] or something.

Similar Threads

  1. Incompatible types
    By coltragon in forum New To Java
    Replies: 5
    Last Post: 01-15-2010, 05:47 PM
  2. Replies: 7
    Last Post: 08-28-2009, 09:23 AM
  3. Replies: 3
    Last Post: 12-14-2008, 02:52 PM
  4. 'Incompatible operand' fault
    By fatnic388 in forum New To Java
    Replies: 3
    Last Post: 12-01-2007, 08:05 PM
  5. problem with scanner class:incompatible types
    By fred in forum New To Java
    Replies: 1
    Last Post: 07-20-2007, 08:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •