Follow us on Facebook

Header Ads

This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Welcome to JAVA POint

Continue Statement in Java.(JAVA)

                                         Continue Statement in Java.

Continue Statement  is generally utilized inside circles. At whatever point it is experienced inside a Loops, 

control straightforwardly leaps to the start of the circle for next cycle, skirting the execution of proclamations inside circle's body for the current emphasis. 

This is especially helpful when you need to proceed with the circle however don't need the remainder of the statements(after proceed with articulation) in circle body to execute for that specific cycle. 

Synatx:

Continue word followed by semi colon. 

proceed; 

Model: proceed with explanation inside for circle 

public class ContinueExample { 

public static void main(String args[]){ 

for (int j=0; j<=6; j++) 

{ 

on the off chance that (j==4) 

{ 

proceed; 

} 

System.out.print(j+" "); 

} 

} 

} 


Output: 

0 1 2 3 5 6 


As you may have seen, the worth 4 is absent in the yield, why? since when the worth of variable j is 4, the program experienced a proceed with explanation, 

which takes it to leap toward the start of for circle for next cycle, skirting the assertions for current emphasis (that is the explanation println didn't execute when the worth of j was 4). 

flow Diagram of Continue Statement 





Proceed with Statement 


Model: Use of proceed in While circle 

Same thing you can see here. We are repeating this circle from 10 to 0 for counter worth and when the counter worth is 7 the circle skirted the print articulation and began next emphasis of the while circle. 

public class ContinueExample2 { 

public static void main(String args[]){ 

int counter=10; 

while (counter >=0) 

{

on the off chance that (counter==7) 

{ 

counter- - ; 

proceed; 

} 

System.out.print(counter+" "); 

counter- - ; 

} 

} 

} 


Output: 


10 9 8 6 5 4 3 2 1 0 


Illustration of proceed in do-While circle 

public class ContinueExample3 { 

public static void main(String args[]){ 

int j=0; 

do 

{ 

in the event that (j==7) 

{ 

j++; 

proceed; 

} 

System.out.print(j+ " "); 

j++; 

}while(j<10); 

} 

} 

Yield: 

0 1 2 3 4 5 6 8 9



Do-While loop With Example.(JAVA)

 

                                              Do-While loop With Example.


In the last instructional exercise, we talked about while circle. In this instructional exercise we will talk about do-while circle in java. do-while circle is like while circle, anyway there is a contrast between them: In while circle, condition is assessed before the execution of circle's body however in do-while circle condition is assessed after the execution of circle's body. 

Synatx  of do-while circle: 

do 

{ 

statement(s); 


} while(condition); 

How do-while circle functions? 

In the first place, the assertions inside circle execute and afterward the condition gets assessed, on the off chance that the condition return s valid, the control gets moved to the "do" else it leaps to the following assertion after do-while. 





do while circle java 

do-while circle model 

class DoWhileLoopExample { 

public static void main(String args[]){ 

int i=10; 

do{ 

System.out.println(i); 

I- - ; 

}while(i>1); 

} 

} 

Output: 

10 

9 

8 

7 

6 

5 

4 

3 

2


Model: Iterating exhibit utilizing do-while Loops

Here we have a whole number cluster and we are repeating the exhibit and showing every component utilizing do-while circle. 

class DoWhileLoopExample2 { 

public static void main(String args[]){ 

int arr[]={2,11,45,9}; 

/I begins with 0 as exhibit record begins with 0

int i=0; 

do{ 

System.out.println(arr[i]); 

i++; 

}while(i<4); 

} 

} 

Output: 

2 

11 

45 

9


While Loops With Example(java)

                                                     While Loops With Example.


While Loops Java With Example.


In the last instructional exercise, we examined for circle. In this instructional exercise we will talk about while circle.

 As talked about in past instructional exercise, circles are utilized to execute a bunch of proclamations over and again until a specific condition is fulfilled. 

Sentence structure of while circle 

while(condition) 

{

statement(s); 

} 


How while Loop functions? 




In while circle, condition is assessed first and in the event that it returns valid, the proclamations inside while circle execute. 

At the point when condition returns bogus, the control emerges from circle and leaps to the follolowwing assertion after while circle. 


Note: The significant highlight note when utilizing while circle is that we need to utilize addition or decrement explanation inside while circle so the circle variable gets changed on every empha

 and sooner or later condition returns bogus.

This way we can end the execution of while circle in any case the circle would execute inconclusively. 

while circle java 

Straightforward while circle model 

class WhileLoopExample { 

public static void main(String args[]){ 

int i=10; 

while(i>1){ 

System.out.println(i); 

I- - ; 

} 

} 

} 

Output: 

10

9 

8 

7 

6 

5 

4 

3 

2 

Boundless while circle 

class WhileLoopExample2 { 

public static void main(String args[]){ 

int i=10; 

while(i>1)

{ 

System.out.println(i); 

i++; 

} 

} 

} 

This circle could never end, its a boundless while circle. This is on the grounds that condtion is i>1 which would consistently be valid as we are increasing the worth of I inside while circle. 

Here is another illustration of boundless while circle:

while (true){ 

statement(s);

} 

Model: Iterating an exhibit utilizing while circle 

Here we are emphasizing and showing exhibit components utilizing while circle. 

class WhileLoopExample3 { 

public static void main(String args[]){ 

int arr[]={2,11,45,9}; 

/I begins with 0 as cluster record begins with 0 as well 

int i=0; 

while(i<4){ 

System.out.println(arr[i]); 


i++; 


} 


} 


} 


Ouput: 


2 


11 


45 


9

****************************************************************************************

Do-While loops.


In the last instructional exercise, we examined while circle. In this instructional exercise we will examine do-while circle in java. 

do-while circle is like while circle, anyway there is a distinction between them: In while circle, 

condition is assessed before the execution of circle's body however in do-while circle condition is assessed after the execution of circle's body. 


Sentence structure of do-while circle: 


do 


{ 


statement(s); 

} while(condition); 


How do-while circle functions? 

To start with, the assertions inside circle execute and afterward the condition gets assed, on the off chance that the condition returns valid,

the control gets moved to the "do" else it leaps to the following assertion after do-while. 

do while circle java 

do-while circle model 

class DoWhileLoopExample { 

public static void main(String args[]){ 

int i=10; 

do{ 

System.out.println(i); 

I- - ; 

}while(i>1); 

} 

} 

Yield: 

10 

9 

8 

7 

6 

5 

4

3 

2 

Model: Iterating cluster utilizing do-while circle 

Here we have a number exhibit and we are emphasizing the cluster and showing every component utilizing do-while circle. 

class DoWhileLoopExample2 { 

public static void main(String args[]){ 

int arr[]={2,11,45,9}; 

/I begins with 0 as cluster file begins with 0 

int i=0; 

do{ 

System.out.println(arr[i]); 

i++; 

}while(i<4); 

} 

} 

Yield: 

2 

11 

45 

9


While Loops Java With Example.(JAVA)

                                         While Loops Java With Example.

In the last instructional exercise, we examined for circle. In this instructional exercise we will talk about while circle.

 As talked about in past instructional exercise, circles are utilized to execute a bunch of proclamations over and again until a specific condition is fulfilled. 

Sentence structure of while circle 

while(condition) 

{ 

statement(s); 

} 

How while Loop functions? 

In while circle, condition is assessed first and in the event that it returns valid, the proclamations inside while circle execute. 

At the point when condition returns bogus, the control emerges from circle and leaps to the following assertion after while circle. 

Note: The significant highlight note when utilizing while circle is that we need to utilize addition or decrement explanation inside while circle so the circle variable gets changed on every emphasis

 and sooner or later condition returns bogus.

This way we can end the execution of while circle in any case the circle would execute inconclusively. 

while circle java 

Straightforward while circle model 

class WhileLoopExample { 

public static void main(String args[]){ 

int i=10; 

while(i>1){ 

System.out.println(i); 

I- - ; 

}

} 

} 

Output: 

10 

9 

8 

7 

6 

5 

4 

3 

2 

Boundless while circle 

class WhileLoopExample2 { 

public static void main(String args[]){ 

int i=10; 

while(i>1) 

{ 

System.out.println(i); 

i++; 

} 

} 

} 

This circle could never end, its a boundless while circle. This is on the grounds that condition is i>1 which would consistently be valid as we are increasing the worth of I inside while circle. 

Here is another illustration of boundless while circle: 

while (true){ 

statement(s); 

} 

Model: Iterating an exhibit utilizing while circle 

Here we are emphasizing and showing exhibit components utilizing while circle. 

class WhileLoopExample3 { 

public static void main(String args[]){ 

int arr[]={2,11,45,9}; 

/I begins with 0 as cluster record begins with 0 as well 

int i=0; 

while(i<4){ 

System.out.println(arr[i]); 

i++; 

} 

} 

} 

Ouput: 

2 

11 

45 

9


For Loop In java(JAVA)

                                                     For Loop In java

Loops are utilized to execute a bunch of explanations over and over until a specific condition is fulfilled. 

In Java we have three kinds of fundamental circles: for, while and do-while. In this instructional exercise we will figure out how to use "for circle" in Java. 

Punctuation of for Loops: 

for(initialization; condition ; increase/decrement) 

{ 

statement(s); 

} 


Stream of Execution of the for Loop 

As a program executes, the mediator consistently monitors which explanation is going to be executed. We call this the control stream, or the progression of execution of the program. 

for loops Java 

Initial phase: In for circle, introduction happens sole one time, which implies that the instatement part of for  loops just executes once. 


Second step: Condition in for circle is assessed on every emphasis, assuming the condition is valid, the explanations inside for circle body gets executed.

 When the condition returns bogus, the explanations in for circle doesn't execute and the control gets moved to the following assertion in the program after for Loops. 

Third step: After each execution of for circle's body, the augmentation/decrement part of for circle executes that refreshes the circle counter. 


Fourth step: After third step, the control leaps to second step and condition is rethought. 

Illustration of Simple For loops

class ForLoopExample { 

public static void main(String args[]){ 

for(int i=10; i>1; I- - ){ 

System.out.println("The worth of I is: "+i); 

} 

} 

} 


The Output of this program is: 

The worth of I is: 10 

The worth of I is: 9 

The worth of I is: 8 

The worth of I is: 7 

The worth of I is: 6 

The worth of I is: 5 

The worth of I is: 4 

The worth of I is: 3 

The worth of I is: 2 

In the above program: 

int i=1 is introduction articulation 

i>1 is condition(Boolean articulation) 

I–Decrement activity 

Boundless for loops 

The significance of Boolean articulation and addition/decrement activity co-appointment: 

class ForLoopExample2 { 

public static void main(String args[]){ 

for(int i=1; i>=1; i++){ 

System.out.println("The worth of I is: "+i); 

} 

} 

} 


This is a limitless circle as the condition could stay away forever bogus. 

The introduction step is setting up the worth of variable I to 1, since we are increasing the worth of I, it would consistently be more noteworthy than 1 (the Boolean articulation: i>1) so it could stay away for the indefinite future bogus. This would at last prompt the endless circle condition. Consequently it is imperative to see the co-appointment between Boolean articulation and addition/decrement activity to decide if the circle would end sooner or later of time or not. 

Here is another illustration of boundless for loops: 

/boundless circle 

for ( ; ) { 

/statement(s) 

} 

For circle guide to emphasize an exhibit: 

Here we are emphasizing and showing exhibit components utilizing the for circle. 

class ForLoopExample3 { 

public static void main(String args[]){ 

int arr[]={2,11,45,9}; 

/I begins with 0 as cluster list begins with 0 as well 

for(int i=0; i<arr.length; i++){ 

System.out.println(arr[i]); 

}

} 

} 

Output: 

2 

11 

45 

9 

Improved For Loops: 

Upgraded for circle is valuable when you need to repeat Array/Collections, it is not difficult to compose and comprehend. 

We should take the very model that we have composed above and change it utilizing upgraded for Loops. 

class ForLoopExample3 { 

public static void main(String args[]){ 

int arr[]={2,11,45,9}; 

for (int num : arr) { 

System.out.println(num); 

} 

} 

} 

Output: 

2 

11 

45 

9 

Note: In the above model, I have announced the num as int in the upgraded for circle. This will change contingent upon the information kind of cluster. For instance, the upgraded for circle for string type would resemble this: 

String arr[]={"hi","hello","bye"}; 

for (String str : arr) { 

System.out.println(str); 

}


Switch case statement in Java (JAVA)

  Switch Case Statement in Java.


Switch case proclamation is utilized when we have number of alternatives (or decisions) and we may have to play out an alternate assignment for every decision. 

The linguistic structure of Switch case explanation resembles this – 

switch (variable or a whole number articulation) 

{ 

case consistent: 

/Java code

case consistent: 


/Java code 


; 


default: 


/Java code 


; 


} 


Switch Case proclamation is for the most part utilized with break articulation despite the fact that it is discretionary.

 We will initially see a model without break explanation and afterward we will examine switch case with break 


A Simple Switch Case Example 


public class SwitchCaseExample1 { 


public static void main(String args[]){ 


int num=2; 


switch(num+2) 


{ 


case 1: 


System.out.println("Case1: Value is: "+num); 


case 2: 


System.out.println("Case2: Value is: "+num); 


case 3: 


System.out.println("Case3: Value is: "+num); 


default: 


System.out.println("Default: Value is: "+num); 


} 


} 


} 


Output: 


Default: Value is: 2 


Clarification: In switch I gave an articulation, you can give variable too. I gave num+2, where num esteem is 2 and after expansion the articulation came about

 4. Since there is no case characterized with esteem 4 the default case got executed. This is the reason we should utilize default in switch case, so that if there is no trick that coordinates with the condition, the default block gets executed. 


Switch Case Flow Diagram 


First the variable, worth or articulation which is given in the switch enclosure is assessed and afterward dependent on the outcome, the relating case block is executed that coordinates with the outcome. 


switch case stream outline 


Break proclamation in Switch Case 


Break proclamation is discretionary in switch case however you would utilize it pretty much every time you manage switch case.

 Before we examine about break proclamation, Let's view the model beneath where I am not utilizing the break explanation: 


public class SwitchCaseExample2 { 


public static void main(String args[]){ 


int i=2; 


switch(i) 


{ 


case 1: 


System.out.println("Case1 "); 


case 2: 


System.out.println("Case2 "); 


case 3: 


System.out.println("Case3 "); 


case 4: 


System.out.println("Case4 "); 


default: 


System.out.println("Default "); 


} 


} 


} 


Yield: 


Case2 


Case3 


Case4 


Default 


In the above program, we have passed number worth 2 to the switch, so the control changed to the case 2, anyway we don't have break proclamation after the case 2 that made the stream pass to the resulting cases till the end. The answer for this issue is break explanation 


Break explanations are utilized when you need your program-stream to emerge from the switch body. 

At whatever point a break articulation is experienced in the switch body, the execution stream would straightforwardly emerge from the switch, disregarding rest of the cases 


We should take a similar model however this time with break articulation. 


Model with break proclamation 


public class SwitchCaseExample2 { 

public static void main(String args[]){ 

int i=2; 

switch(i) 

{ 

case 1: 

System.out.println("Case1 "); 

break; 

case 2: 

System.out.println("Case2 "); 

break; 

case 3: 

System.out.println("Case3 ");

break; 

case 4: 

System.out.println("Case4 "); 

break; 

default: 

System.out.println("Default "); 

} 

} 

} 


Output: 


Case2 

Presently you can see that lone case 2 had been executed, rest of the cases were disregarded. 

For what reason didn't I utilize break explanation after default? 

The control would itself emerge from the switch after default so I didn't utilize it, notwithstanding assuming you actually need to utilize the break after default, you can utilize it, there is no damage in doing that. 

Not many focuses about Switch Case 

1) Case doesn't generally have to have request 1, 2, 3, etc. It can have any number worth after case catchphrase.

 Likewise, case shouldn't be in a climbing request consistently, you can indicate them in any request dependent on the prerequisite. 

2) You can likewise utilize characters in switch case. for instance – 

public class SwitchCaseExample2 { 

public static void main(String args[]){ 

scorch ch='b'; 

switch(ch) 

{ 

case 'd': 

System.out.println("Case1 "); 

break; 

case 'b': 

System.out.println("Case2 "); 

break; 

case 'x': 

System.out.println("Case3 "); 

break; 

case 'y': 

System.out.println("Case4 "); 

break; 

default: 

System.out.println("Default "); 

} 

} 

} 


3) The articulation given inside switch should bring about a consistent worth else it would not be legitimate. 

For instance: 

Legitimate articulations for switch: 

switch(1+2+23) 

switch(1*2+3%4) 

Invalid switch articulations: 

switch(ab+cd) 

switch(a+b+c) 

4) Nesting of switch proclamations are permitted, which implies you can have switch explanations inside another switch.

 Anyway settled switch proclamations ought to be kept away from as it makes program more intricate and less discernible.


IF,If.....else Statement in java with Examples(JAVA)

                             IF,If.....else Statement in java with Examples

At the point when we need to execute a bunch of proclamations dependent on a condition then we need to utilize control stream explanations. For instance, in the event that a number is more noteworthy than nothing, we need to print "Positive Number" however assuming it is under nothing, we need to print "Negative Number". For this situation we have two print proclamations in the program, yet just each print articulation executes in turn dependent on the info esteem. We will perceive how to compose such sort of conditions in the java program utilizing control articulations. 

In this instructional exercise, we will see four kinds of control articulations that you can use in java programs dependent on the prerequisite: In this instructional exercise we will cover following restrictive explanations: 

a) if articulation 

b) settled if articulation 

c) if-else articulation 

d) if-else-if articulation 

On the off chance that articulation

On the off chance that articulation comprises a condition, trailed by explanation or a bunch of proclamations as demonstrated underneath: 

if(condition){ 

Statement(s); 

} 

The assertions gets executed just when the given condition is valid. On the off chance that the condition is bogus, the explanations inside if proclamation body are totally overlooked. 

in the event that assertion stream graph 

Illustration of if explanation 

public class IfStatementExample { 

public static void main(String args[]){ 

int num=70; 

on the off chance that( num < 100 ){ 

/* This println proclamation will just execute, 

* if the above condition is valid 

*/ 

System.out.println("number is under 100"); 

} 

} 

} 

Output: 

number is under 100 

Settled if explanation in Java 

When there is an in the event that assertion inside another if proclamation, it is known as the settled if explanation. 

The design of settled if resembles this: 

if(condition_1) { 

Statement1(s); 

if(condition_2) { 

Statement2(s); 

} 

}

Statement1 would execute if the condition_1 is valid. Statement2 would possibly execute if both the conditions( condition_1 and condition_2) are valid. 

Illustration of Nested if articulation 

public class NestedIfExample { 

public static void main(String args[]){ 

int num=70; 

in the event that( num < 100 ){ 

System.out.println("number is under 100"); 

if(num > 50){ 

System.out.println("number is more noteworthy than 50"); 

} 

} 

} 

} 

Output: 

number is under 100IF,If.....else Statement in java with Examples

At the point when we need to execute a bunch of proclamations dependent on a condition then we need to utilize control stream explanations. For instance, in the event that a number is more noteworthy than nothing, we need to print "Positive Number" however assuming it is under nothing, we need to print "Negative Number". For this situation we have two print proclamations in the program, yet just each print articulation executes in turn dependent on the info esteem. We will perceive how to compose such sort of conditions in the java program utilizing control articulations. 

In this instructional exercise, we will see four kinds of control articulations that you can use in java programs dependent on the prerequisite: In this instructional exercise we will cover following restrictive explanations: 

a) if articulation 

b) settled if articulation 

c) if-else articulation 

d) if-else-if articulation 

On the off chance that articulation

On the off chance that articulation comprises a condition, trailed by explanation or a bunch of proclamations as demonstrated underneath: 

if(condition){ 

Statement(s); 

} 

The assertions gets executed just when the given condition is valid. On the off chance that the condition is bogus, the explanations inside if proclamation body are totally overlooked. 

in the event that assertion stream graph 

Illustration of if explanation 

public class IfStatementExample { 

public static void main(String args[]){ 

int num=70; 

on the off chance that( num < 100 ){ 

/* This println proclamation will just execute, 


* if the above condition is valid 


*/ 

System.out.println("number is under 100"); 

} 

} 

} 

Output: 


number is under 100 

Settled if explanation in Java 

When there is an in the event that assertion inside another if proclamation, it is known as the settled if explanation. 

The design of settled if resembles this: 

if(condition_1) { 

Statement1(s); 

if(condition_2) { 

Statement2(s); 

} 

} 

Statement1 would execute if the condition_1 is valid. Statement2 would possibly execute if both the conditions( condition_1 and condition_2) are valid. 

Illustration of Nested if articulation 

public class NestedIfExample { 

public static void main(String args[]){ 

int num=70; 

in the event that( num < 100 ){ 

System.out.println("number is under 100"); 

if(num > 50){ 

System.out.println("number is more noteworthy than 50"); 

} 

} 

} 

} 

Output: 

number is under 100 

number is more noteworthy than 50 

In the event that else proclamation in Java 

This is the manner by which an if-else proclamation looks: 

if(condition) { 

Statement(s); 

}

else { 

Statement(s); 

} 

The assertions inside "if" would execute if the condition is valid, and the assertions inside "else" would execute if the condition is bogus. 

On the off chance that else stream chart

Illustration of if-else explanation 

public class IfElseExample { 

public static void main(String args[]){ 

int num=120; 

on the off chance that( num < 50 ){ 

System.out.println("num is under 50"); 

} 

else { 

System.out.println("num is more prominent than or equivalent 50"); 

} 

} 

} 

Output: 

num is more prominent than or equivalnt 50 

on the off chance that else-if Statement 

in the event that else-if explanation is utilized when we need to check different conditions.

 In this proclamation we have just one "if" and one "else", anyway we can have different "else if".

It is otherwise called if else if stepping stool. This is what it looks like: 

if(condition_1) { 

/*if condition_1 is genuine execute this*/ 

statement(s); 

} 

else if(condition_2) 

{ 

/* execute this if condition_1 isn't met and 

* condition_2 is met 

*/ 

statement(s); 

} 

else if(condition_3) { 

/* execute this if condition_1 and condition_2 are 

* not met and condition_3 is met 

*/ 

statement(s); 

} 

else { 

/* if none of the condition is valid 

* at that point these assertions gets executed 

*/ 

statement(s); 

} 

Note: The main highlight note here is that in if-else-if articulation, when the condition is met, the relating set of proclamations get executed, rest gets overlooked. 

Assuming none of the condition is met, the explanations inside "else" gets executed. 

Illustration of if-else-if 

public class IfElseIfExample { 

public static void main(String args[]){ 

int num=1234; 

if(num <100 && num>=1) { 

System.out.println("Its a two digit number"); 

} 

else if(num <1000 && num>=100) { 

System.out.println("Its a three digit number"); 

} 

else if(num <10000 && num>=1000) { 

System.out.println("Its a four digit number"); 

} 

else if(num <100000 && num>=10000) { 

System.out.println("Its a five digit number"); 

} 

else { 

System.out.println("number isn't between 1 and 99999"); 

} 

}

} 

Output:  

number is more noteworthy than 50 

In the event that else proclamation in Java 

This is the manner by which an if-else proclamation looks: 

if(condition) { 

Statement(s); 

} 

else { 

Statement(s); 

} 

The assertions inside "if" would execute if the condition is valid, and the assertions inside "else" would execute if the condition is bogus. 

On the off chance that else stream chart 

Illustration of if-else explanation 

public class IfElseExample { 

public static void main(String args[]){ 

int num=120; 

on the off chance that( num < 50 ){ 

System.out.println("num is under 50"); 

} 

else { 

System.out.println("num is more prominent than or equivalent 50"); 

} 

} 

} 

Output: 

num is more prominent than or equivalent 50 

on the off chance that else-if Statement 

in the event that else-if explanation is utilized when we need to check different conditions.

 In this proclamation we have just one "if" and one "else", anyway we can have different "else if".

It is otherwise called if else if stepping stool. This is what it looks like: 

if(condition_1) { 

/*if condition_1 is genuine execute this*/ 

statement(s); 

} 

else if(condition_2) { 

/* execute this if condition_1 isn't met and 

* condition_2 is met 

*/ 

statement(s); 

} 

else if(condition_3) { 

/* execute this if condition_1 and condition_2 are 

* not met and condition_3 is met 


*/ 

statement(s); 

} 

else { 

/* if none of the condition is valid 

* at that point these assertions gets executed 

*/ 

statement(s); 

} 


Note: The main highlight note here is that in if-else-if articulation, when the condition is met, the relating set of proclamations get executed, rest gets overlooked. 

Assuming none of the condition is met, the explanations inside "else" gets executed. 

Illustration of if-else-if 

public class IfElseIfExample { 

public static void main(String args[]){ 

int num=1234; 

if(num <100 && num>=1) { 

System.out.println("Its a two digit number"); 

} 

else if(num <1000 && num>=100) { 

System.out.println("Its a three digit number"); 

} 

else if(num <10000 && num>=1000) { 

System.out.println("Its a four digit number"); 

} 

else if(num <100000 && num>=10000) { 

System.out.println("Its a five digit number"); 

} 

else { 

System.out.println("number isn't between 1 and 99999"); 

} 

} 

} 

Output: 


C language and C++ progaming