java - How to pass a String argument to ArrayList parameter -


i trying pass string argument arraylist parameter so:

class {  public void testa (arraylist arrayinput) {       // implement function       system.out.println("in testa function");    }   string = "new";   testa(a); } 

i because want use same function pass both string values , arraylist values. there work around?

thanks, sony

// option 1: print in string - preferred public void testa(arraylist<string> list) {     for(string str : list) testa(str); }  public void testa(string s) {     system.out.println(s); }    // option2: print in list - not preferred public void testa(arraylist<string> list) {     for(string str : list) system.out.println(str); }  public void testa(string s) {     arraylist<string> list = new arraylist<string>();     list.add(s);     testa(list); } 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -