Class 9 ICSE - Java
Class 9th Java aims to empower students by enabling them to build their own applications introducing some effective tools to enable them to enhance their knowledge, broaden horizons, foster creativity, improve the quality of work and increase efficiency.
It also develops logical and analytical thinking so that they can easily solve interactive programs. Students learn fundamental concepts of computing using object oriented approach in one computer language with a clear idea of ethical issues involved in the field of computing
Class 9th java topics includes revision of class 9th, constructors, user-defined methods, objects and classes, library classes , etc.
Nested for loop
If a loop exists inside the body of another loop, it's called a nested loop.
When we are using a for loop inside another for loop this is called as nested for loop. The inner loop must
have a different name for loop control variable so that it does not conflict with the outer loop. We can use
the nested loop in java to create patterns like full pyramid, half pyramid, inverted pyramid, and so
on.
Syntax :
for (initialization; condition; update)
{
for(initialization; condition; update)
{
// inner loop statements.
}
// outer loop statements.
}
Let us understand this through some examples :
Example 1:
Output :
Example 2:
Output :
for (initialization; condition; update) { for(initialization; condition; update) { // inner loop statements. } // outer loop statements. }