How to pass a list element as function parameter?

119 views Asked by At

I have a char array: my_array={"a","b","c"}

And I need to get 1 specific element and put it as function parameter

For example: function myFunction({"b"}){}

I tried this but got an error:

unexpected character

I learned from TTCN-3 and I try this on it.

1

There are 1 answers

0
surendra babu On BEST ANSWER

This will help you. Use this kind of code will help you to pass one parameter each time.

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