Need help in refactor multiple while loops java

          int startIndex = 0;
          int endIndex = -1;                                                                       
          int count = 0;
          while (dummy.substring(endIndex + 1).trim().indexOf(')') != -1
                && dummy.substring(endIndex + 1).trim().length() != 0) {
            dummy = dummy.substring(endIndex + 1).trim();
            while (dummy.length() <= 1 && dummy.startsWith(")")) {
                dummy= dummy.substring(++count);
            }}

i have tried to add second while in separate method but it wont allow me bcoz of count, can we apply java8 or any ?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum