int cannot be converted to int []

Melanie

new to programming here and i keep getting the error message, 'incompatible types, int cannot be converted to int []', the question is to add R1& R2 together if they are of equal lengths and if not print a message that says 'the arrays must be same length', if that matters, not sure where im going wrong, any help would be greatly appreciated

 public int[] arrayAdd(int[] R1, int[] R2)
{
    int[] sumArray= new int[R1.length];

    if( R1.length!= R2.length)
    {
        System.out.println("The arrays must be same length");
}
else
{
    for(int i=0; i< R1.length; i++)
    for (int j=0; j<R2.length; j++)

    {

        sumArray= R1[i]+ R2[j]; // Error
    }
}
    return sumArray;
}
Rahul Raj
           sumArray[i]= R1[i]+ R2[j]; // updated line

you need to assign to an array element, but you were doing it wrong.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

int[][] cannot be converted into int

From Dev

double[][] cannot be converted to int[][]

From Dev

Constant value cannot be converted to int

From Dev

ArrayList <Word> cannot be converted to int

From Dev

ArrayList <Word> cannot be converted to int

From Dev

Java int cannot be converted to boolean

From Java

Java incompatible types: int cannot be converted to int[]

From Dev

Java incompatible types: int cannot be converted to int[]

From Dev

error: incompatible types: int[][] cannot be converted to int

From Java

incompatible types: int cannot be converted to T

From Dev

java.lang.Object cannot be converted to int

From Java

Java : incompatible types; int cannot be converted to string

From Dev

incompatible types: void cannot be converted to int

From Dev

incompatible types: BigInteger cannot be converted to int

From Dev

String[] cannot be converted to int by method invocation conversion?

From Dev

incompatible types: BigInteger cannot be converted to int

From Dev

Cannot call an ObjC method taking int in Swift because Int32 cannot be converted to Int

From Dev

Java: toString error "error: incompatible types: int cannot be converted to String"

From Dev

app setBackground() error: incompatible types: int cannot be converted to Drawable

From Dev

Incompatible types : Int cannot be converted to "class" data type

From Dev

actual argument Date cannot be converted to int by method invocation conversion

From Dev

JAVA: Incompatible types: int cannot be converted to java.lang.String

From Dev

Object of type 'System.Int32' cannot be converted to type 'System.Int32[]'

From Dev

Float converted into int for big values

From Dev

Why is Char implicitly converted to a Int?

From Dev

string converted to int is too large

From Dev

Collection could not be converted to int Laravel

From Dev

How can an int be converted into an id?

From Dev

Rational number converted to long int

Related Related

  1. 1

    int[][] cannot be converted into int

  2. 2

    double[][] cannot be converted to int[][]

  3. 3

    Constant value cannot be converted to int

  4. 4

    ArrayList <Word> cannot be converted to int

  5. 5

    ArrayList <Word> cannot be converted to int

  6. 6

    Java int cannot be converted to boolean

  7. 7

    Java incompatible types: int cannot be converted to int[]

  8. 8

    Java incompatible types: int cannot be converted to int[]

  9. 9

    error: incompatible types: int[][] cannot be converted to int

  10. 10

    incompatible types: int cannot be converted to T

  11. 11

    java.lang.Object cannot be converted to int

  12. 12

    Java : incompatible types; int cannot be converted to string

  13. 13

    incompatible types: void cannot be converted to int

  14. 14

    incompatible types: BigInteger cannot be converted to int

  15. 15

    String[] cannot be converted to int by method invocation conversion?

  16. 16

    incompatible types: BigInteger cannot be converted to int

  17. 17

    Cannot call an ObjC method taking int in Swift because Int32 cannot be converted to Int

  18. 18

    Java: toString error "error: incompatible types: int cannot be converted to String"

  19. 19

    app setBackground() error: incompatible types: int cannot be converted to Drawable

  20. 20

    Incompatible types : Int cannot be converted to "class" data type

  21. 21

    actual argument Date cannot be converted to int by method invocation conversion

  22. 22

    JAVA: Incompatible types: int cannot be converted to java.lang.String

  23. 23

    Object of type 'System.Int32' cannot be converted to type 'System.Int32[]'

  24. 24

    Float converted into int for big values

  25. 25

    Why is Char implicitly converted to a Int?

  26. 26

    string converted to int is too large

  27. 27

    Collection could not be converted to int Laravel

  28. 28

    How can an int be converted into an id?

  29. 29

    Rational number converted to long int

HotTag

Archive