Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class NestedForLoops{
- public static void main(String[] args){
- //Example 1
- for (int i = 1; i <= 3; i++) {
- for (int j = 1; j <= 2; j++) {
- System.out.println("six");
- }
- }
- //Example 2
- // for (int i = 1; i <= 5; i++) {
- // for (int j = 1; j <= 10; j++) {
- // System.out.print(i + " " + j);
- // }
- // System.out.println(); // to end the line
- // }
- //Example 3
- // for (int i = 1; i <= 5; i++) {
- // for (int j = 1; j <= 10; j++) {
- // System.out.print( (i*j) + " ");
- // }
- // System.out.println(); // to end the line
- // }
- //Example 4
- // for (int i = 1; i <= 4; i++) {
- // for (int j = 1; j <= 5; j++) {
- // System.out.print("*");
- // }
- // System.out.println();
- // }
- //Example 5
- // for (int i = 1; i <= 6; i++) {
- // for (int j = 1; j <= i; j++) {
- // System.out.print("*");
- // }
- // System.out.println();
- // }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement