TermCommentPost For Continue Statement

Add Comment

    • not similar to if/else..
      Suppose i have an example to print 1-50, but at every 3rd place i have to print “sanjeev” and at every 5th place have to print “Singh”.
      Like 1 , 2, sanjeev, 4 , singh…..so on…

  • i have an example to print 1-50, but at every 3rd place i have to print “sanjeev” and at every 5th place have to print “Singh”.
    Like 1 , 2, sanjeev, 4 , singh…..so on…

    public class Test21 {
    public static void main(String[] args) {
    for(int i=1; i<=50; i++){
    if (i%15==0 ) {
    System.out.println(“sanjeev ranjan”);
    continue;
    }
    if (i%5==0 ) {
    System.out.println(“sanjeev”);
    continue;
    }
    if (i%3==0 ) {
    System.out.println(“ranjan”);
    continue;
    }
    System.out.println(i);
    }

    }

    }

Sponsors

Facebook Fans