Thursday, 1 March 2018

Do while and Foreach Loop in Java









Do While


package javaapplication7;


public class JavaApplication7 {

   
    public static void main(String[] args)
    {
        int i=10;
        do 
        {
            System.out.println(i);
            i--;
        } while (i>0);
        
       
    }
    
}

Foreach 


package javaapplication8;


public class JavaApplication8 {

    
    public static void main(String[] args) 
    {
        String[] fruits = new String[] { "Orange", "Apple", "Pear", "Strawberry" };

     for (String x : fruits)
     {
         System.out.println(x);
    
     }
    
}
}

No comments:

Post a Comment

Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...