DEV Community

Discussion on: How can I improve this while loop code snippet?

Collapse
 
fabulousyap profile image
fabulous.yap

maybe...

        char c;
        while (!Character.isWhitespace(c=source.charAt(currentCharIndex++))) {
            //do code magic here...
        }

or

        char c;
        while (!Character.isWhitespace(c=source.charAt(currentCharIndex))) {
            currentCharIndex++;
            //more code magic happen after this...
        }

but I know nothing of what happen next tho... I assume currentCharIndex will be increment somewhere in the loop...