Thread: How to resolve: Returning 3d array problem

1. Member
Join Date
Oct 2012
Posts
1
Rep Power
0

How to resolve: Returning 3d array problem

Hello! My problem is that i created a class where i did a method and this method returning with a 3d array. When i wud like to use this array in an other class suddenly its a empty array with full of zero.
If someone could help me out i'd appriciate it thx.
Here's the code:
Java Code:
```public class BetarEgy extends Raktar{

BetarEgy(){
super.Randomallapot();
}

public int[][][] betar1(int textfield){
int tomb[][][]=new int[4][25][2];
boolean betarolt=false;

for(int k=0;k<textfield;k++){
for (int i=0;i<4;i++){
for(int j=0;j<25;j++){
if(raktar[i][j][0]==0 && raktar[i][j][1]==0 && raktar[i][j][2]==0){
raktar[i][j][0]=1 + gen.nextInt(25)+(i*4);
raktar[i][j][1]=gen.nextInt(2);
raktar[i][j][2]=gen.nextInt(8)+1;
tomb[i][j][0]=i;
tomb[i][j][1]=j;
System.out.println(" Sor: "+tomb[i][j][0]+" Oszlop: "+tomb[i][j][1]);

}
}
}

}
}

}```

Above i checked with a print method thatthe array does contain the numbers what i need and it does

Java Code:
```public class Fifo extends BetarEgy{
private final BetarKetto os= new BetarKetto();
// private final BetarEgy t= new BetarEgy();
boolean kitarolt=false;
final int kitartomb[][][]=betar1(textfield); //This is the array what i actually wud like to use

double ido[]= new double[100];
double szamol;
public double[] FifoKitar1(int textfield){
for(int k=0; k<textfield;k++){
for(int i=0;i<3;i++){
for (int j=0;j<24;j++){
if(i==kitartomb[i][j][0] && j==kitartomb[i][j][1]){
System.out.println(" SorFifo: "+kitartomb[i][j][0]+" OszlopFifo: "+kitartomb[i][j][1]);
tav=((Integer)raktar[i][j][0]).intValue();
szamol=tav/(double)seb;
ido[k] = szamol;
//System.out.print(" Idő: "+ido[k]+"\nTavolsag: "+tav+" Raktaradattav: "+raktar[i][j][0]);
raktar[i][j][0]=0;
raktar[i][j][1]=0;
raktar[i][j][2]=0;
kitarolt=true;
break;
}
}
if(kitarolt==true){
break;
}
}
}
return ido;
}```
Thx for take a look at it :)
Last edited by djpista; 10-07-2012 at 09:47 PM.

2. Re: How to resolve: Returning 3d array problem

Please edit you post and wrap the code in code tags. See: BB Code List - Java Programming Forum

Posting Permissions

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