Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lista.Alapok;
- public class Main {
- public static void printSquareStar(int number) {
- if (number<5) System.out.println("Invalid Value");
- else {
- int[][] array = new int[number][number];
- for (int i = 0; i < array.length; i++) {
- for (int j = 0; j < array.length; j++) {
- if ((i == 0 || i == number - 1) || (i == j) || (i + j == number - 1) || (j == 0 || j == number - 1))
- System.out.print("*");
- else System.out.print(" ");
- }
- System.out.println();
- }
- }
- }
- public static void main(String[] args) {
- printSquareStar(-8);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement