Its just a OOP test I was doing, could you please help me understanding the concept of how to set the Multidimensional array value by passing the object. Please check the below code;
public class agnts {
private int rate[][] = new int [4][5];
public agnts(){
rate[0][1] = new pric(25);
rate[1][1]=new pric(30);
rate[2][1]= new pric(45);
rate[3][1]=new pric(55);
}
}
class pric {
//int pric [][]= new int [4][5];
int pric;
public pric(int p){
this.pric=p;
}
public int getPric(){
return pric;
}
}
public static void main(String[] args) {
agnts tz= new agnts();
}
I get an error of type incompatible required:int found:pric Am I doing something wrong? please advise.
int[][]and your are trying to set its elements to your classpric. You need to dorate[X][Y]=new pric(Z).getPric();. Better yet, read this.