Passing a string array as a parameter to a function java

后端 未结 8 997
清酒与你
清酒与你 2020-12-16 20:09

I would like to pass a string array as a parameter to a function. Please look at the code below

String[] stringArray = {\'a\', \'b\', \'c\', \'d\', \'e\'};
         


        
8条回答
  •  攒了一身酷
    2020-12-16 20:23

    I believe this should be the way this is done...

    public void function(String [] array){
    ....
    }
    

    And the calling will be done like...

    public void test(){
        String[] stringArray = {"a","b","c","d","e","f","g","h","t","k","k","k","l","k"};
        function(stringArray);
    }
    

提交回复
热议问题