【问题标题】:How to pass a list element as function parameter?如何将列表元素作为函数参数传递?
【发布时间】:2017-08-29 07:35:40
【问题描述】:

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

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

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

我试过了,但出错了:

意外字符

我从 TTCN-3 学习并在上面尝试了这个。

【问题讨论】:

    标签: arrays parameter-passing ttcn


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2021-10-17
      • 2022-01-02
      • 1970-01-01
      • 2014-12-17
      • 2012-05-24
      • 2017-04-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多