Skip to main content
Code Review

Return to Answer

Notice removed Content dispute by Jamal
Post Locked by Jamal
Notice added Content dispute by Jamal
Notice removed Content dispute by Community Bot
Post Unlocked by Community Bot
Post Locked by rolfl
Notice added Content dispute by rolfl
Post Undeleted by rolfl
Post Deleted by Jamal
added 128 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Alternative way to make Rectangle.

public class myclass {

// Input the size of the Rectangle.

 // Input the size of the Rectangle.
 static int hight = 8;
static int width = 8;
public static void main(String[] args) {
 line(width);
 for (int m = 0; m < hight - 2; m++) {
 starWithSpace();
 System.out.println();
 }
 line(width);
}
public static void space() {
 System.out.print(" ");
}
public static void printStar() {
 System.out.print("*");
}
public static void starWithSpace() {
 printStar();
 for (int i = 0; i <= hight - 2; i++) {
 space();
 }
 printStar();
}
public static void line(int width) {
 for (int header = 0; header <= width; header++) {
 printStar();
 }
 System.out.println("");
}}

Alternative way to make Rectangle.

public class myclass {

// Input the size of the Rectangle.

static int hight = 8;
static int width = 8;
public static void main(String[] args) {
 line(width);
 for (int m = 0; m < hight - 2; m++) {
 starWithSpace();
 System.out.println();
 }
 line(width);
}
public static void space() {
 System.out.print(" ");
}
public static void printStar() {
 System.out.print("*");
}
public static void starWithSpace() {
 printStar();
 for (int i = 0; i <= hight - 2; i++) {
 space();
 }
 printStar();
}
public static void line(int width) {
 for (int header = 0; header <= width; header++) {
 printStar();
 }
 System.out.println("");
}}

Alternative way to make Rectangle.

public class myclass {
 // Input the size of the Rectangle.
 static int hight = 8;
static int width = 8;
public static void main(String[] args) {
 line(width);
 for (int m = 0; m < hight - 2; m++) {
 starWithSpace();
 System.out.println();
 }
 line(width);
}
public static void space() {
 System.out.print(" ");
}
public static void printStar() {
 System.out.print("*");
}
public static void starWithSpace() {
 printStar();
 for (int i = 0; i <= hight - 2; i++) {
 space();
 }
 printStar();
}
public static void line(int width) {
 for (int header = 0; header <= width; header++) {
 printStar();
 }
 System.out.println("");
}}
Thanx to gnanz and Miroslav Popov
Source Link

Alternative way to make Rectangle.

public class myclass {

// Input the size of the Rectangle.

static int hight = 8;
static int width = 8;
public static void main(String[] args) {
 line(width);
 for (int m = 0; m <6;< hight - 2; m++) {
 starWithSpace();
 System.out.println();
 }
 line(width);
}
public static void space() {
 System.out.print(" ");
}
public static void printStar() {
 System.out.print("*");
}
public static void starWithSpace() {
 printStar();
 for (int i = 0; i <= 6;hight - 2; i++) {
 space();
 }
 printStar();
}
public static void line(int width) {
 for (int header = 0; header <= 8;width; header++) {
 printStar();
 }
 System.out.println("");
}}

Alternative way to make Rectangle.

class myclass {
public static void main(String[] args) {
 line();
 for (int m = 0; m <6; m++) {
 starWithSpace();
 System.out.println();
 }
 line();
}
public static void space() {
 System.out.print(" ");
}
public static void printStar() {
 System.out.print("*");
}
public static void starWithSpace() {
 printStar();
 for (int i = 0; i <= 6; i++) {
 space();
 }
 printStar();
}
public static void line() {
 for (int header = 0; header <= 8; header++) {
 printStar();
 }
 System.out.println("");
}}

Alternative way to make Rectangle.

public class myclass {

// Input the size of the Rectangle.

static int hight = 8;
static int width = 8;
public static void main(String[] args) {
 line(width);
 for (int m = 0; m < hight - 2; m++) {
 starWithSpace();
 System.out.println();
 }
 line(width);
}
public static void space() {
 System.out.print(" ");
}
public static void printStar() {
 System.out.print("*");
}
public static void starWithSpace() {
 printStar();
 for (int i = 0; i <= hight - 2; i++) {
 space();
 }
 printStar();
}
public static void line(int width) {
 for (int header = 0; header <= width; header++) {
 printStar();
 }
 System.out.println("");
}}
added 38 characters in body
Source Link

Alternative way to make Rectangle.

class myclass {
public static void main(String[] args) {
 line();
 for (int m = 0; m <6; m++) {
 starWithSpace();
 System.out.println();
 }
 line();
}
public static void space() {
 System.out.print(" ");
}
public static void printStar() {
 System.out.print("*");
}
public static void starWithSpace() {
 printStar();
 for (int i = 0; i <= 6; i++) {
 space();
 }
 printStar();
}
public static void line() {
 for (int header = 0; header <= 8; header++) {
 printStar();
 }
 System.out.println("");
}}

}

class myclass {
public static void main(String[] args) {
 line();
 for (int m = 0; m <6; m++) {
 starWithSpace();
 System.out.println();
 }
 line();
}
public static void space() {
 System.out.print(" ");
}
public static void printStar() {
 System.out.print("*");
}
public static void starWithSpace() {
 printStar();
 for (int i = 0; i <= 6; i++) {
 space();
 }
 printStar();
}
public static void line() {
 for (int header = 0; header <= 8; header++) {
 printStar();
 }
 System.out.println("");
}

}

Alternative way to make Rectangle.

class myclass {
public static void main(String[] args) {
 line();
 for (int m = 0; m <6; m++) {
 starWithSpace();
 System.out.println();
 }
 line();
}
public static void space() {
 System.out.print(" ");
}
public static void printStar() {
 System.out.print("*");
}
public static void starWithSpace() {
 printStar();
 for (int i = 0; i <= 6; i++) {
 space();
 }
 printStar();
}
public static void line() {
 for (int header = 0; header <= 8; header++) {
 printStar();
 }
 System.out.println("");
}}
Source Link
Loading
lang-java

AltStyle によって変換されたページ (->オリジナル) /