Java invoking a method with array parameter -


i wrote following function:

public void enterlessonnames(string[] names)         {             string msg="";              (int i=0;i<names.length;i++)             {                  msg=msg+names[i];             }              system.out.println(msg);  } 

i want call that, giving input:

enterlessonnames({"math","art"} ); 

how can call in main?

enterlessonnames(names[{"math","art"} ]); 

it not of them.

multiple markers @ line:  - syntax error, insert ")" complete methodinvocation - syntax error on token ",", delete token - syntax error, insert ";" complete statement - syntax error on tokens, delete these tokens 

like this:

enterlessonnames( new string[] { "a", "b" } ); 

fyi, java naming conventions imply method names have first letter of each word in name start capital letter except first word starts non-capital. in case: enterlessonnames.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -