title: java: How do I confirm an array is already created in an Array Operation Menu
body: <p>so I'm making this array operations menu and I'm having problems on my first option which is to &quot;create an array&quot;. I'm supposed to input the size of the array here, but if it's &lt; 5 or &gt; 20 it will send an error message, that I can do. But I'm also supposed to to show an error message if an array is already created. How can I do that? thanks for the response.</p>
  <pre><code>class process{
     Scanner in = new Scanner(System.in); 
     int choice1 =0;
     int limit1;
     int array[];
    
     public void m(){
      System.out.println(&quot;                   ARRAY OPERATION&quot;);
      System.out.println(&quot;                        menu&quot;);
      System.out.println(&quot;                 [1] Create Array&quot;);
      System.out.println(&quot;                 [2] Insert Element&quot;);
      System.out.println(&quot;                 [3] Search&quot;);
      System.out.println(&quot;                 [4] Display&quot;);
      System.out.println(&quot;                 [5] Delete&quot;);
      System.out.println(&quot;                 [0] Stop&quot;);
      System.out.print(&quot;                 Enter choice:&quot;);
       e();
    }
      
    public void e(){
      
      
       choice1 = in.nextInt();
       cls();
       
       switch(choice1){
        case 1:
         {
           
          System.out.println(&quot;Create Array&quot;);
          System.out.println(&quot;Enter the limit of your array: &quot;);
          limit1 = in.nextInt();
          
          
          if(limit1 &lt;5){
              System.out.println(&quot;Error: Minimum limit exceeded&quot;); 
              System.out.println(&quot;Going back to main menu&quot;);
              m(); //loop to main menu
          }
          else if(limit1 &gt;20){
              System.out.println(&quot;Error: Maximum limit exceeded&quot;);
              System.out.println(&quot;Going back to main menu&quot;);
              m(); //loop to main menu
          }
          else if(limit1 &gt;=5 || limit1 &lt;=20){
          System.out.println(&quot;An array with a limit of &quot; + limit1 + &quot; has been created&quot;);
          array = new int[limit1];
          m();
       }
       }
  </code></pre>