This Java code defines a class called Xpattern with a main method that uses nested for loops to print out a cross pattern of asterisks. The inner loop iterates from 1 to 5 and prints an asterisk if the difference or sum of the counters i and j is equal to 0 or 6, otherwise it prints a space; this is repeated over 5 lines printed with each iteration of the outer loop.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
28 views
Class Xpattern
This Java code defines a class called Xpattern with a main method that uses nested for loops to print out a cross pattern of asterisks. The inner loop iterates from 1 to 5 and prints an asterisk if the difference or sum of the counters i and j is equal to 0 or 6, otherwise it prints a space; this is repeated over 5 lines printed with each iteration of the outer loop.