About 46,600 results
Open links in new tab
  1. Drawing shapes using java for loops - Stack Overflow

    Apr 7, 2015 · how do i draw an ''x'' shape using atericks with a given size w/ a nested for loop?

  2. java - How to draw rectangles using a loop? - Stack Overflow

    Apr 18, 2016 · Declare y outside of the loop, or use x to calculate the rectangles position. Either like this: graph2D.drawRect(170, y, 20, 50); y = y + 45; Or like this: graph2D.drawRect(170, (x * 45) + 180, 20, 50);

  3. java - Creating a triangle with for loops - Stack Overflow

    I need to draw a simple triangle using for loops. I can make a half triangle, but I don't know how to add to my current loop to form a full triangle. for (int i = 0; i < 6; i++) { for (int j = 0; j < i; j++) { System.out.print("*"); } System.out.println(""); }

  4. Java Program to Draw a Rectangle using For loop

    Dec 4, 2020 · Java program to draw a rectangle using for loop. In this article, you will learn how to draw a rectangle in java using for loop. public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int r = 0, c = 0, i, j; // r - denotes the number of rows // c - denotes the number of columns .

  5. 6.1. Nested Loops · Programming Basics with Java - SoftUni Global

    Chapter 6.1 Nested Loops. This chapter will discuss nested loops in the Java language. We will use for loops to draw different figures containing symbols and signs arranged in rows and columns on the console.

  6. Drawing a pyramid using loops in Java - StackTips

    Below example prints star like pyramid structure using loop in java. // void main public static void main(String[] args) { int depth = 10; int s = depth, m; for (int i = 1; i < = depth; i++) { m = s; while (s > 0) { System.out.print(" "); s--; for (int j = 1; j < = i; j++) { System.out.print("* "); System.out.print("\n"); s = m - 1; * * .

  7. How to print a triangle rectangle pattern (from left to right and …

    Sep 20, 2019 · In this brief article, we will explain you easily a way of drawing the famous triangles using loops in Java. As logic to print a left oriented triangle with asterisks in Java, we will create a loop that will iterate the number of rows that the user wants for the triangle.

  8. Lab 3: Ch. 3G: Graphics - Building Java Programs

    Modify your previous Java program to draw the following output. Use a for loop with your parameterized method to draw faces at different positions.

  9. java - Using loop to draw line - Stack Overflow

    Oct 13, 2015 · DrawPanel panel = new DrawPanel(); JFrame application = new JFrame(); application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); application.add(panel); // add the panel to the frame . application.setSize(250, 250); // set the size of the frame. application.setVisible(true); // make the frame visible . What did I missed out?

  10. Building Shapes With Loops : The Coders Lexicon

    Mar 3, 2008 · Using the Java language, this article covers the project of building shapes using loops and asterisks. It is written in a way to be easily converted to C++ if need be.