In one of my previous post we have printed the Pyramid pattern. In this short tutorial we are going to print the Diamond pattern using java for loop.
Output:
You may also like:
public class StarDiamond { public static void main(String[] args) { int num = 5; for (int i = 1; i <= num; i++) { for (int j = num; j >= i; j--) { System.out.print(" "); } for (int m = 1; m <= i; m++) { System.out.print(" *"); } System.out.print("\n"); } for (int i = 1; i <= num; i++) { for (int j = 1; j <= i; j++) { System.out.print(" "); } for (int m = num; m >= i; m--) { System.out.print(" *"); } System.out.print("\n"); } } }
Output:
You may also like:
this code was really help to me thanks
ReplyDeleteThank you, I used it...
ReplyDeleteThanks for this nice article Java Star Pattern Programs
ReplyDeleteHow to Write these pattern code
ReplyDelete*
** **
*** ***
** **
*
How to Write this program to Print Star Pattern in Java
Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here.
ReplyDeleteBest Training Instittue
I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeleteBest Training and Real Time Support
Android Training
I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeleteOnline IT Selfplaced Videos
Sales Force Selfplaced Videos
My Sql Selfplaced Videos
I love the podcasts available on this site.
ReplyDelete