java - Function is calling itself multiple times -


i've written function calls 3 times more should. call once in program, executes 4 times in total. can explain me problem?

 public static string[] mainbooker(document doc, int counter){             system.out.println("test");             queue<string> mainbooker = new linkedlist<string>();             elements span = doc.select("td");             for(int = counter+1 ; < counter +21; i++){                 string inf = span.eq(i).text();                 if(counter%2 == 0 && i%2 == 0){                     if(!inf.equals("")){                         if(inf.contains("'"))                             inf = inf.replaceall("'", "\'");                         mainbooker.add(inf);                     }                 }                 else if(counter%2 != 0 && i%2 != 0){                     if(!inf.equals("")){                         if(inf.contains("'"))                             inf = inf.replaceall("'", "\'");                         mainbooker.add(inf);                     }                 }             }                       string[] mainbooker_info = new string[mainbooker.size()];              int = 0;             (string info : mainbooker) {                 mainbooker_info[i] = info;                 writetofile(mainbooker_info[i]);                 i++;             }               //stack:             //m/v || firstname || middlename || lastname || dob              // zipcode+ number || street || country || phonenumber || email             return mainbooker_info;     } 

i call in if statement:

else if(inf.contains("main booker") ||  inf.contains("haupt-bucher") || inf.contains("hoofdboeker")){                   string[] result = mainbooker(doc, i);                   if(!result[2].equals("-")){                                   informationbasic.add(result[1] +" "+result[2]+ " "+ result[3]);                 }                 else if(result[2].equals("-")){                     informationbasic.add(result[1] + " "+ result[3]);                 }                 mainbooker.addall(arrays.aslist(mainbooker(doc, i)));             } 

in code,

else if(inf.contains("main booker") ||  inf.contains("haupt-bucher") || inf.contains("hoofdboeker")){               if(!mainbooker(doc, i)[2].equals("-")){                               informationbasic.add(mainbooker(doc, i)[1] +" "+mainbooker(doc, i)[2]+ " "+ mainbooker(doc, i)[3]);             }             else if(mainbooker(doc, i)[2].equals("-")){                 informationbasic.add(mainbooker(doc, i)[1] + " "+ mainbooker(doc, i)[3]);             }             mainbooker.addall(arrays.aslist(mainbooker(doc, i)));         } 

mainbooker has been call multiple times. try instead:

else if(inf.contains("main booker") ||  inf.contains("haupt-bucher") || inf.contains("hoofdboeker")){ string[] result = mainbooker(doc, i);   if(!result[2].equals("-")){                   informationbasic.add(result[1] +" "+result[2]+ " "+ result[3]); } else if(result[2].equals("-")){     informationbasic.add(result[1] + " "+ result[3]); } mainbooker.addall(arrays.aslist(result));} 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -