Tutorialslot.com

youtube facebook twitter gmail pinterest

Continue Statement in Java

The continue statement skips the currently executing loop and transfers the control directly to the conditional expression that controls the loop.Any intermediate code is bypassed in all the looping statements.

Example:
public class Continue
{
public static void main(String[] args)
{

    StringBuffer search = new StringBuffer("saravanan is programmer at Tutorialslot");
    int max = search.length();
    int numPs = 0;

    for (int i = 0; i < max; i++)
    {
      if (search.charAt(i) != 'a')
        continue;
      numPs++;
      search.setCharAt(i, 'a');
    }
    System.out.println("Found " + numPs + " a's in the string.");
    System.out.println(search);
}
}


Output:
Found 7 a's in the string.
saravanan is programmer at Tutorialslot



Advertisement Powered By Google Adsense






IF YOU LIKE THIS TUTORIALS PLEASE SHARE

Share on whatsapp

POPULAR TAGS

Java java tutorials learn java java programming tutorial learn java online learning java professionals tutorials Multithreading Generics Object Oriented Language Methods Polymorphism Inheritance