简体   繁体   English

二进制运算符“ *”的错误操作数类型

[英]Bad operand type for Binary operator “*”

Bad operand type for Binary operator "*" 二进制运算符“ *”的操作数类型错误

I am getting the error during compilation as Bad operand type of Binary operator saying that: first type: int second type: int[] and i have to use this logic only. 我在编译期间由于二进制运算符的错误操作数类型而收到错误消息:第一种类型:int第二种类型:int [],我只需要使用此逻辑。 Following is a part of my program 以下是我程序的一部分

public static int pmean(int[] ar){
    int[][] a = new int[ar.length][ar.length];
    int k=0;
    int min=0;
    int sum=0;
    for(int i=0;i<ar.length;i++){
        k=i+1;
        for(int j=0;j<ar.length;j++){
            a[i][j]= (k * a[j]);//error at this line
            k++;
            if(k==ar.length+1)
                k=1;
        }
    }

a[i][j]= (k * a[j]); a[j] is an array, you probably meant a[i][j] a [j]是一个数组,您可能是说a [i] [j]

a is a two dimensional array so a[j] is an array. a是二维数组,因此a [j]是数组。 You cant multiple and int with an array 你不能用数组整数和整数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM