Sunday 3 August 2014

How to Use FOR LOOP IN JAVA

Structure of the Problem Requirements 


Loops are very important term in programming. The loops are use for the repeation of a instrcution in a programming . Condition can also be apply in loops according to the problems. Her is simple example of for loop which take five number from user and then again using for loop show that numbers.


Source Code 


package com.ancodingpoint.www;

import java.util.Scanner;

public class Arrays_sorting{

 public static void main(String[] args) {

     Scanner input = new Scanner (System.in);
     int num [] = new int [5];
     for( int i =0; i<5;i++ )
     {
         System.out.println(" Enter Your Number Here......!");
         num[i] = input.nextInt();
     }
     System.out.println(" These Number are Taken with using for Loop !");
    for (int i =0; i <5; i++)
    {
        System.out.println(num[i]);
    }
    }
 }   

Output of the Program

Java Programming
Java Loop






Share it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

0 comments:

Post a Comment