title: Creating a Hollow Rectangle Using Asterisks in Java
body: <p>This is a homework assignment. However, I've completed almost all the code and am missing just one piece. The program is supposed to print out a rectangle according to user specified height and width values. The rectangle needs to be hollow, however it is not. I'm new to Java, so I'm not sure what to implement in my code to make the rectangle hollow. Any help would be appreciated. Thanks!
  Example. </p>
  
  <p>Height =4 Width =8</p>
  
  <p>What I get</p>
  
  <pre><code>********
  ********
  ********
  ********
  </code></pre>
  
  <p>What I need</p>
  
  <pre><code>********
  *      *
  *      *
  ********
  </code></pre>
  
  <p>Below is my code. Thanks for the help!</p>
  
  <pre><code>import java.util.Scanner;
  public class Rectangle 
  {
  public static void main(String[] args)
  {
  int height;
  int width;
  Scanner keyboard = new Scanner(System.in); 
  System.out.println("Please enter the height of the rectangle.");
  height = keyboard.nextInt();
  if (height &lt; 0)
  {
      height = 1;
  }
  System.out.println("Please enter the width of the rectangle.");
  width = keyboard.nextInt();
  if(width &lt; 0)
  {
      width = 1;
  }
  
  for(int h = 0; h &lt; height; h++) 
  { 
      for(int w = 0; w &lt; width; w++) 
      { 
          System.out.print("*"); 
      } 
      System.out.println(" "); 
  } 
  }
  }
  </code></pre>