Passing a string array as a parameter to a function java

后端 未结 8 1012
清酒与你
清酒与你 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:34

    More than likely your method declaration is incorrect. Make sure the methods parameter is of type String array (String[]) and not simply String and that you use double quotes around your strings in the array declaration.

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

提交回复
热议问题