KnowledgeBoat Logo

Java Series Programs

Write a program in Java to print the series:

8, 88, 888, 8888, 88888, 888888

Java

Java Nested for Loops

30 Likes

Answer

public class Kboat8Series
{
    public static void main(String args[]) {
        
        for (int i = 1; i <= 6; i++) {
            for (int j = 0; j < i; j++) {
                System.out.print('8');
            }
            System.out.print(' ');
        }
    }
}

Output

BlueJ output of Write a program in Java to print the series: 8, 88, 888, 8888, 88888, 888888

Answered By

12 Likes