• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

ITechOasis

Ease Your IT+Tech Experience !

  • Home
  • All Courses
  • Microsoft Excel
  • Webinar
You are here: Home / Programming / Java / Star Grid Patterns In Java

January 12, 2019 By ITechOasis Leave a Comment

Star Grid Patterns In Java

  • Print Star Grid Pattern using For Loop: Rectangle
public static void main(String[] args) {

	for (int i = 1; i <= 4; i++) {

		for (int j = 1; j <= 4; j++) {

			System.out.print("* ");
		}

	System.out.println("");
	}

}
  • Print Star Grid Pattern using For Loop: Triangle 
public static void main(String[] args) {

	for (int i = 1; i <= 4; i++) {

		for (int j = 1; j <= i; j++) {

			System.out.print("* ");
		}

		System.out.println("");
	}

}

OR >

public static void main(String[] args) {

	for (int i = 1; i <= 4; i++) {

		for (int j = 1; j <= 4; j++) {
				
		System.out.print("* ");

		if (i==j)
			break;
				
		}

		System.out.println("");
	}

}

Print Border Star Pattern :



Filed Under: Java

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published.

Primary Sidebar

Categories

Recent Posts

  • How to Find a Prime Number?
  • Labeled Break Statement – Java
  • Print ASCII Values in Java
  • Print ArmStrong Number – Java
  • Star Grid Patterns In Java

Recent Comments

  • torrent on How to reverse Integer? – Java
  • king on List of Popular ‘Software Testing’ SitesĀ 

Footer

  • About Us
  • Tech ++
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Services

Creative Commons License
ITechOasis.com is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.

© Copyright 2015-2020 ITechOasis Training & Solutions · All Rights Reserved ·