Counting the Number of Non Blank Characters in a String | Java Example

by Dinesh Thakur Category: Control Structures

Print Number from 1 to 10 Except 5

by Dinesh Thakur Category: Control Structures

Infinite For loop Example | Java Examples

by Dinesh Thakur Category: Control Structures

Jump Statements in Java Example

by Dinesh Thakur Category: Control Structures

In Java, Jump statements are used to unconditionally transfer program control from one point to elsewhere in the program. Jump statements are primarily used to interrupt loop or switch-case instantly. Java supports three jump statements: break, continue, and return.

Print all the Prime Numbers up to 100

by Dinesh Thakur Category: Control Structures

we have seen how to test whether a given number is prime or not. The program segment given below uses a for loop to test each number in a given range and print it if it is prime.

Prime Number Program in Java Using BufferedReader Example.

by Dinesh Thakur Category: Control Structures

Nested For Loop in Java Example

by Dinesh Thakur Category: Control Structures

Nested loop means one loop inside the other. When a loop is written inside the other loop, a condition is essential to maintain: the inner loop will not cross the boundary of the outer loop. That is, the inner loop will begin and end inside the outer loop. We can have any number of loops one inside the other.

Enter 10 Number and Print the Number of Positive, Negative and Zeros Number

by Dinesh Thakur Category: Control Structures

In this example we use BufferedReader class for Reading text from a character-input stream. After Enter any 5 Number we check if number ==0 then is zero if number greater than 0 then it is positive other wise negative.

Enter a String from keyboard and check whether it Palindrome or Not

by Dinesh Thakur Category: Control Structures

Length():-This method is a predefined method of String class present in java. Lang package. It is used to determine the length of string and return type of this method is int type.

Sum of first n Sequence Numbers in Java Example

by Dinesh Thakur Category: Control Structures

Print the table of an input number up till 10 times in Java Example

by Dinesh Thakur Category: Control Structures

Print n Even Numbers in Java Example

by Dinesh Thakur Category: Control Structures

Print n Sequence Numbers in Java Example

by Dinesh Thakur Category: Control Structures

Odd Numbers from 1 To 100 in Java Example

by Dinesh Thakur Category: Control Structures

For Loop | Java Examples

by Dinesh Thakur Category: Control Structures

The for loop enables code to execute repeatedly until a boolean expression evaluates to false.

Do-while Loop in Java, do while syntax Java Example

by Dinesh Thakur Category: Control Structures

The do loop enables us to repeatedly execute a block of code until a boolean expression evaluates to false. It is almost identical to the while loop with the difference that here the logical expression is evaluated at the bottom of the loop rather than the top. This means that the contents of the loop will execute at least once.

While Loop in Java Example

by Dinesh Thakur Category: Control Structures

The while loop is a construct that repeatedly executes a block of code as long as a boolean condition remains true. The logical expression in while loop is evaluated first. If the logical expression evaluates to false, the body of while loop will not execute even once. If the logical expression in while evaluates to true, the statements in the body of while loop are executed. After executing the body, control jumps again at the top to recheck whether the boolean expression is still true or not. The body of the loop will continue to execute until the expression evaluates to false. When the logical expression becomes false, control continues the execution with the statements following while loop.

Nested Switch Statements Java Example

by Dinesh Thakur Category: Control Structures

The switch statement is a multi-way decision making statement which selects one of several alternatives based on the value of an integer variable or expression. The switch statement is mainly used to replace multiple if-else-if statement. The if-else-if statement causes performance degradation as several conditions need to be evaluated before a particular condition is satisfied.

Switch Statement in Java Example

by Dinesh Thakur Category: Control Structures

When there is requirement of several branching i.e. if we need several if statements, it is better to use switch statement. In other words, switch is a variation of if statement which performs multiway branching.

Nested If in Java Example

by Dinesh Thakur Category: Control Structures

When we have if or if else statement within another if construct or else construct, we call it nested if.

Page 2 of 4

Dinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles