Results 1 to 2 of 2
  1. #1
    djpista is offline Member
    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Default 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]); 
                                  
                            }
                        }
                    }
                    
        }
        return tomb;    
        }
        
    }

    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 08:47 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,397
    Rep Power
    25

    Default 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
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Returning Array Row
    By Zocheyado in forum New To Java
    Replies: 2
    Last Post: 04-15-2011, 02:23 AM
  2. returning an array weird problem
    By mcleanj in forum New To Java
    Replies: 4
    Last Post: 01-28-2011, 05:29 AM
  3. Problem returning Array values Please help
    By drgnfire25 in forum New To Java
    Replies: 4
    Last Post: 01-12-2011, 12:53 AM
  4. Someone come resolve this problem of mine, please!!!
    By gabriel landry in forum Advanced Java
    Replies: 19
    Last Post: 11-12-2010, 11:32 AM
  5. Returning array problem.
    By Chase in forum New To Java
    Replies: 4
    Last Post: 10-21-2008, 09:07 PM

Posting Permissions

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