Java Programming | Creating 2’s Table

Introduction

This is a tutorial for creating 2’s table in java. The program is given below that prints the table of 2. The program is extendable. Go enjoy the program. Lets begin…………

Program for two’s table in java.

// the name of our class its public
public class TwoTable {
	//void main
		public static void main (String[] args)
		{
			//declare int
			int i;
			//for loops
			for(i=2;i<=20;i++)
			{
			System.out.println(i);
			i++;
			}
		}
}

Output

2
4
6
8
10
12
14
16
18
20

How does it work

The numbers are directly printed. no need to input.

Extending it.

This program can be extended by creating the same program by using while loop and do-while loop or by creating table of any other number. Go extend it.

Explanation.

  1. Declare the class as public
  2. Add the void main function
  3. Add the loop
  4. Add system.out.println() function to print the number.
  5. Add i++.

At the end.

You learnt creating the Java program for Creating 2’s Table. So now enjoy the program.

Please comment on the post and share it.
And like it if you liked.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s