我有一个char数组:my_array={"a","b","c"}
我需要得到一个特定的元素,并把它作为函数参数
例如:function myFunction({"b"}){}
我试过了,但有个错误:
意外字符
我从TTCN-3中学到的,我在上面试用了这个。
发布于 2017-08-29 07:51:53
这会帮到你的。使用这种代码可以帮助您每次传递一个参数。
public class MyClass {
public static void main(String args[]) {
MyClass mc = new MyClass();
char my_array[]={'a','b','c'};
char returnValue;
for(int i=0;i<my_array.length;i++){
returnValue = mc.charReturn(my_array[i]);
System.out.println("Got it from method:"+returnValue);
}
}
public char charReturn(char fromClass){
return fromClass;
}
}https://stackoverflow.com/questions/45933286
复制相似问题