Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Recursion executing line after break statement

$
0
0

private String getPhrasedvalue(int current_value, int next_value, String str) throws SQLException { String[] words = str.split(" "); String current = words[current_value]; String next = words[next_value]; StringBuilder sb = new StringBuilder(); String lastToken = words[words.length-1]; StringBuilder finalstring = new StringBuilder(); sb.append(current).append("-").append(next); sb.toString();

    Outer:
    while (true) {
        boolean flag = FindDB(sb.toString());
        {
            if (flag == true) {
                next_value++;
                sb.append("-").append(words[next_value]);

            } else {

                int i = sb.toString().lastIndexOf("-");
                sb.replace(i, i + 1, " ");
                current_value = next_value;
                next_value = next_value + 1;
                if(next_value==words.length)
                {
                    break Outer;
                }

                getPhrasedvalue(current_value, next_value, str);
            }


        }

    }

After going to if loop of break statement it will executing getPhrasedvalue(current_value, next_value, str); again .what is the problem? and how to get final appended value of sb?


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>