# Shiqianfeng JAVA classes against the war, March 25 #

Day 10 Shiqianfeng against the war in class learning;
JAVA_DAY8;
learning content there the previous day's work and methods (functions) return parameter;
Chinese world refuel refueling!!
I Come!

/*
设计一个方法,使用*打印正方形。正方形的边长,由参数传入
*/

import java.util.Scanner;

public class Home3Work{
	public static void main(String[]atgs){
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入正方形的边长");
		int side = sc.nextInt();
		if(side<0){
			System.out.println("输入有误");
		}else{
			square(side);
		}
	}
	
	public static void square(int l){
		for(int i = 1;i < l;i++){
			for(int j = 1;j < l;j++){
				System.out.print("*");
			}
			System.out.print("\n");
		}
	}
}
Published 11 original articles · won praise 3 · Views 390

Guess you like

Origin blog.csdn.net/yuxinganggame/article/details/105107807