2012-02-16 66 views
1

我正在使用Matlab代码(使用javabuilder java)从Java中的对数正态分布中进行采样。将Matlab输出转换为Java中的ArrayList

下面是代码:

import demo2.*; 
import com.mathworks.toolbox.javabuilder.*; 
import java.util.*; 

public class ht { 

/** 
* @param args 
*/ 
public static void main(String[] args) { 
    // TODO Auto-generated method stub 
Object[] x = null; //?? What does Object[] mean?// 
ArrayList th = new ArrayList(); 
demo y = null; 

try { 
    y = new demo(); //the class created by Matlab builder ja// 
    x=y.lognorma(1, 10); //function to sample the distribution// 


} catch (MWException e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
} 
} 
} 

是什么对象[]的意思是在这种背景下,如何在Java中更改对象[]×成正常的ArrayList?

回答

1

在 “捕捉” 块的末尾添加

th = new ArrayList(x); 

List<Object> res = Arrays.asList(x);