skip to main | skip to sidebar

Java Programs and Examples with Output

Pages

▼
 
  • RSS
  • Twitter
Saturday, January 7, 2012

Printing Table In java using While Loop

Posted by Admin at 1:40 AM – 2 comments
 
Here is a Java Program to Print the Table

public class Table { 
   public static void main(String[] args) {     
      int no = Integer.parseInt(args[0]);

     // count from i = 1 to 10
      int i = 1;
      while (i <= 10) {
         System.out.println(i*no); 
          i++;
      }
   }
}
 /**************************
  *
  * % java Table 5
  * 5
  * 10 
  * 15
  * 20
  * 25
  * 30
  * 35 
  * 40 
  * 45
  * 50
  *
  **************************/




Explanation of Above Java Program 
In Above Java Program
  1. we are taking command line argument from user.
  2. Initializing the Integer i with 1.
  3. Looping through the WHILE until i is more than 10.
  4. Printing the Value with println.
Labels: Basic Java Programs , While Loop

2 Responses so far.

  1. deep says:
    August 10, 2012 at 6:29 AM

    thanks for giving a such a easy solution

  2. lg says:
    September 18, 2012 at 2:58 PM

    something wrong in this program with variable......!!!!!!

Leave a Reply

Newer Post Older Post
Subscribe to: Post Comments ( Atom )
  • Popular
  • Recent
  • Archives
Powered by Blogger.
 
 
 
© 2011 Java Programs and Examples with Output | Designs by Web2feel & Fab Themes

Bloggerized by DheTemplate.com - Main Blogger