Java Programing laungage

Core Java Tutorial

Introduction of Core Java

How To Install JDk and Set of Path

Syntax of java Program

Difference between Java and C/C++

Advantage and Disadvantage of Java

What is Java

Why Java is not Pure Object Oriented Language

Java has Following Features/Characteristics

Limitation of Java Language and Java Internet

Common Misconception about Java

Simple Program of Java

Integrated Development Environment in java

Compile and Run Java Program

Applet and Comments in Java

Tokens in Java

Keywords in Java

Identifier and Variables in Java

Literals/Constants

Data Type in Java

Assignments and Initialization in Java

Operators in Java

Rule of Precedence in Java

Operator on Integer and Separators in Java Programming

Java Control Flow of Statements

If and If-else Selection Statement

Nested If-else and If-else-If Selection Statement

switch case and conditional operator Selection Statement

for and while Loop

do..while and for each Loop

break and labeled break statement

continue and labeled continue statement

return Statement and exit() Method

Escape Sequence for Special Characters and Unicode Code

Constants and Block or Scope

Statement in Java

Conversions between Numeric Types in Java

Import Statement in Java

User Input in Java using Scanner Class

User Input in Java using Console Class

Array in Java

One Dimensional Array

Two Dimensional Array

Two Dimensional Array Program

Command Line Argument in Java

String args Types in Java

Uneven/Jagged array in java

Math Class Function and Constant

Math Class all Function used in a program

Enumerated Types in Java

Object Oriented Programming v/s Procedural Programming

Object Oriented Programming Concepts in Java

Introduction to Class,Object and Method in Java

Class Declaration in Java

Class & Objects in java

Encapsulation in Java

Modifiers/Visibility for a Class or Interrface or member of a Class

Polymorphism in Java

Runtime polymorphism (dynamic binding or method overriding)

for and while Loop
Previous Home Next

The initialization step is executed first, and only once. The initialization expression initializes the loop it's executed once, as the loop begins. Next the condition expression evaluates to false, the loop terminates. The increment expression is call after each iteration through the loop, it is perfectly acceptable for this expression to increment or decrement a value.

syntax :

for(initialize; condition; increment/decrement )
	{
		staements ;
	}

Example :

class For
{
	public static void main(String args[])
	{
		int n,i;
		n=5;
		for(i=1;i<=n;i++)
		{
			System.out.println(i);
		}
	}
}

 

output :

1
2
3
4
5
while Loop

A while loop is a control structure that allows you to repeat a task a certain number of times. If the condition expression result is true, then the actions inside the loop will be executed. This will continue as long as the expression result is true.

syntax :

initialize;
	while(condition)
	{
		statements ;
		increment/decrement;
	}

Example :

class While
{
	public static void main(String args[])
	{
		int i,n,fact;
		n=5;
		fact=1;
		i=n;
		while(i>=1)
		{
			fact=fact*i;
			i--;
		}
			System.out.print("factorial is "+fact);
	}
}

output :

120
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: