Practice of Java programming basics-I want to display triangles with for statements ①

I made a program that I made when I was a newcomer, now in my second year. For statement again.

Conclusion: I couldn't display the triangle, so I decided to display the rectangle in order.

problem

Please enter the height of the triangle
5
*
**
***
****
*****
****
***
**
*

Progress

I don't know how to make a triangle. .. .. I just remember having a hard time last year. For the time being, I tried to implement it so as to make a quadrangle whose length is the entered integer.

Check32.java


package practice;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Check32 {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		System.out.println("Please enter the length of the rectangle");
		String line;
		try {
			line = reader.readLine();
			int hight = Integer.parseInt(line);
			for( int i = 0; i < hight; i++) {
				for (int j = 0;j < hight;j++) {
					System.out.print("*");
				}
				System.out.println();
			}
		} catch (NumberFormatException e) {
			System.out.println("Please enter an integer");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

The execution result is as follows.

Please enter the length of the rectangle
5
*****
*****
*****
*****
*****

Impressions

I couldn't complete it on my own. (Although it is still in the process of completion) What kind of keyword should I search for in the first place? I was struggling even in that place. I made it by referring to this site. I learned that nesting for creates a table.

The favorite triangle will be carried over to the next.

Recommended Posts

Practice of Java programming basics-I want to display triangles with for statements ①
Practice of Java programming basics-I want to display triangles with for statements ②
[Java] Summary of for statements
Reintroduction to Java for Humanities 0: Understanding the Act of Programming
I want to display the number of orders for today using datetime.
[Java] How to test for null with JUnit
I want to use java8 forEach with index
[Introduction to Java] Basics of java arithmetic (for beginners)
Initialization of for Try to make Java problem TypeScript 5-4
Java programming exercises for newcomers unpopular with active engineers
I want to display the name of the poster of the comment
[For beginners] Minimum sample to display RecyclerView in Java
Introduction to Java for beginners Basic knowledge of Java language ①
I want to transition screens with kotlin and java!
Try connecting to AzureCosmosDB Emulator for Docker with Java
I want to get along with Map [Java beginner]
How to execute WebCamCapture sample of NyARToolkit for Java
Implemented a strong API for "I want to display ~~ on the screen" with simple CQRS
How to use trained model of tensorflow2.0 with Kotlin / Java
I want to make a list with kotlin and java!
I want to make a function with kotlin and java!
Initialization with an empty string to an instance of Java String type
[Java Silver] Things to be aware of regarding switch statements
Even in Java, I want to output true with a == 1 && a == 2 && a == 3
I want to implement various functions with kotlin and java!
A memo to start Java programming with VS Code (2020-04 version)
I want to narrow down the display of docker ps
Be sure to compare the result of Java compareTo with 0
Investigated how to call services with Watson SDK for Java
[Java] I want to test standard input & standard output with JUnit
Java to play with Function
[Java] How to display Wingdings
Connect to DB with Java
Connect to MySQL 8 with Java
Seasonal display with Java switch
Java while and for statements
Returning to the beginning, getting started with Java ② Control statements, loop statements
Utilization of Java array elements, for, length, value, and extended for statements
I want to return to the previous screen with kotlin and java!
The story of Collectors.groupingBy that I want to keep for posterity
[Details] Implementation of consumer applications with Kinesis Client Library for Java
Collection of programming selection tasks to make and remember (Java basics)
[For beginners] Minimum sample to update RecyclerView with DiffUtils in Java
Source to display character array with numberPicker in Android studio (Java)
[Java] I want to perform distinct with the key in the object
How to check for the contents of a java fixed-length string
[Code Pipeline x Elastic Beanstalk] Summary of errors and countermeasures for CI / CD Java applications to Elastic Beanstalk with Code Pipeline