在java中初始化并返回一个字节数组 [英] Initialise and return a byte array in java

查看:187
本文介绍了在java中初始化并返回一个字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的代码中,我必须将一个再见数组(byte [] temp = null;)传递给
函数,该函数被分配并填充其中的数据。在
从函数返回后,它仍为null。我怎样才能找到这个问题的
解决方案。???请帮帮我。

In my code i have to pass a bye array (byte[] temp = null;) to a function which is allocated and filled with data inside it. After returning from function it is still null. How can i find a solution to this problem.??? Please help me.

  byte[] temp = null;
  ret = foo(temp);

  boolean foo(byte[] temp)
  {
      temp = new byte[];
      //fill array
  }


推荐答案

你需要使用它:

 byte[] temp = new byte[some_const];
  ret = foo(temp);

  boolean foo(byte[] temp)
  {
      //fill array
  }

 byte[] temp = null;
  temp  = foo(temp);

  byte[] foo(byte[] temp)
  {    temp = new byte[some_const];
      //fill array
      return temp;
  }

这篇关于在java中初始化并返回一个字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆