0% found this document useful (0 votes)
58 views1 page

Java Code for X Pattern Printing

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.

Uploaded by

Anuj Jain
Copyright
© All Rights Reserved
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% found this document useful (0 votes)
58 views1 page

Java Code for X Pattern Printing

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.

Uploaded by

Anuj Jain
Copyright
© All Rights Reserved
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

class Xpattern

public static void main()

for(int i=1;i<=5;i++)

for(int j=1;j<=5;j++)

if(j-i==0||i+j==6)

[Link]("*");

else

[Link](" ");

[Link]();

You might also like