如何将列表元素作为函数参数传递?

How to pass a list element as function parameter?

我有一个字符数组:my_array={"a","b","c"}

我需要获取 1 个特定元素并将其作为函数参数

例如:function myFunction({"b"}){}

我试过了,但出现错误:

unexpected character

我从 TTCN-3 学到的,我在上面试了一下。

这对你有帮助。使用这种代码将帮助您每次传递一个参数。

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;
        }
    }