Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
Tipo de operando incorrecto para operador binario + primer tipo int[] y segundo tipo int

Estoy tratando de acceder al valor de las definiciones de matriz 2D usando el mapeo de matriz 1D y quiero almacenar ese valor de índice específico en una variable.

La matriz contiene los valores enteros, al usar el concepto de matriz 2D para el mapeo de matriz 1D, aparece el error "Tipo de operando incorrecto para el operador binario + primer tipo int [] y segundo tipo int"

El enunciado en el que se produce el error es:

 D = fill[ (i-1) * seq_2.length + (j-1)]

Estoy tratando de acceder al valor de diagnóstico en el relleno de matriz, es decir, relleno [i-1] [j-1] y quiero almacenarlo en una variable D seq_2. La longitud es el tamaño de las columnas en la matriz.

el código es

 for (i = 1; i <= (seq_1.length); i++) { for (j = 1; j <= (seq_2.length); j++) { D = fill[ (i-1) * seq_2.length + (j-1)]; } }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Está diciendo que el fill es una matriz 2D de tipo int , y D es un entero de tipo primitivo ... está obteniendo el error Bad Operand Type for Binary Operator + first type int[] and second type int porque lo está intentando para asignar la primera dimensión de la matriz 2D de fill a un tipo de datos primitivo int. considere este ejemplo:

 int[][] array = {{1,2},{3,4}}; // 2D array of type int as an example for(int i=0; i<2; i++){ System.out.println(array[i]); // this basically is getClass().getName() + '@' + Integer.toHexString(hashCode()) for(int j=0; j<2; j++){ System.out.println(array[j]); System.out.println(array[i][j]);// this prints out the actual value at the index } } }

La salida:

 [I@15db9742 [I@15db9742 1 [I@6d06d69c 2 [I@6d06d69c [I@15db9742 3 [I@6d06d69c 4

Además, si desea calcular el valor diagonal de una matriz 2D cuadrada , puede hacer, por ejemplo:

 int[][] array = {{1,2,3},{4,5,6}, {7,8,9}}; int diagonalSum = 0; for(int i=0; i<3; i++, System.out.println()){ for(int j=0; j<3; j++){ System.out.print(array[i][j]+"\t"); if(j==i){ diagonalSum+=array[i][j]; } } } System.out.println("\nDiagonal Value is: " + diagonalSum);

La salida:

 1 2 3 4 5 6 7 8 9 Diagonal Value is: 15
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!