- package day2;
- import java.util.Scanner;
- public class PrintSquareBox {
- public static void main(String[] args) {
- int num = 5;
- for (int i = 0; i < num; i++) {
- System.out.print("3 ");
- }
- System.out.println();
- for (int j = 0; j < num - 2; j++) {
- for (int i = 0; i < num; i++) {
- if (i == 0 || i == num - 1) {
- System.out.print("3 ");
- } else {
- System.out.print("1 ");
- }
- }
- System.out.println();
- }
- for (int i = 0; i < num; i++) {
- System.out.print("3 ");
- }
- }
- }
Output:
java program to print square of stars
Related Posts:
To check the given number is Amstrong or Not package date24; public class Amstrong { public static void main(String[] args) { int first = 153; int num = first; int digits = 0; while … Read More
java program to print square of stars package day2; import java.util.Scanner; public class PrintSquareBox { public static void main(String[] args) { int num = 5; for (in… Read More
List of core java topics List of core java topics List of core java topics Java introduction First java program Language fundamentals OOPS Concepts Inner classe… Read More
To print sum of digits: To print sum of digits: public class SumOfDigits { public static void main(String[] args) { int num = 67; System.out.println(getSumOf… Read More
Write a program to Get numbers from String public class StringReplace { public static void main(String[] args) { // TODO Auto-generated method stub String str = "ha656ri… Read More
0 comments:
Post a Comment