有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

将双值数组从一个java类传递到另一个java类

我有一个Java类文件,其中包含我想在另一个Java类文件中使用的双值数组。这是我的代码的简化版本:

文件1。爪哇

public class File1.java{

//code

public void compute
{
    double[] vectorX_U = {0.1, 0.2, 0.5}
}

//i tried this method to pass but it said vectorX_U cannot be resolved to a variable
 public Double[] getvectorX_U() 
 {
     return vectorX_U;
 }

文件2。爪哇

//i attempt to use the array
public void computethis
{
    File1 td = new File1();
    System.out.println(td.getvectorX_U());
}

我能在如何实现这一点上得到一些帮助吗?谢谢


共 (0) 个答案