title: traversing a 2d array and adding indexs to a stack
body: <p>I have a project for school to take my current pacman program and have pacman traverse the 2-d char array to find a pattern to complete the maze.
  I am trying to use a stack and add specific index of my maze to the stack so when pacman reaches the index it pops off and he chooses a direction randomly to another index and so forth until all dots are eaten. My issue is taking my 2d array and finding the index values of the intersections and then adding them to a stack. 
  I am new to java and not really sure how to approach this I posted my maze I have and some code that will use the stack to find the sequence. Thanks in advanced.</p>
  
  <pre><code>private void create() {
      String[] tier = new String[tall];
      tier[0] = "|======================================|";
      tier[1] = "|......................................|";
      tier[2] = "|.====.==========================.====.|";
      tier[3] = "|.||||............................||||.|";
      tier[4] = "|.====.==========================.====.|";
      tier[5] = "|......................................|";
      tier[6] = "|.====================================.|";
      tier[7] = "|......................................|";
      tier[8] = "|.====.======.====----====.======.====.|";
      tier[9] = "|.||||........||        ||........||||.|";
      tier[10] = "|.||||.======.||        ||.======.||||.|";
      tier[11] = "|.||||........||        ||....... ||||.|";
      tier[12] = "|.====.======.============.======.====.|";
      tier[13] = "|......................................|";
      tier[14] = "|.===========..............===========.|";
      tier[15] = "|.............=====  =====.............|";
      tier[16] = "|.=======.===.||$      $||.===.=======.|";
      tier[17] = "|.|||||||.===.=====  =====.===.|||||||.|";
      tier[18] = "|.|||||||......................|||||||.|";
      tier[19] = "|.|||||||.====================.|||||||.|";
      tier[20] = "|.=======......................=======.|";
      tier[21] = "|.==......====================......==.|";
      tier[22] = "|.==.====.======........======.====.==.|";
      tier[23] = "|....====........======........====....|";
      tier[24] = "|======================================|";
      for (int i = 0; i &lt; tall; i++) {
          array[i] = tier[i].toCharArray();
      }
  
  }
  
      public boolean isPattern(Spot b, Spot e) {
      Stack&lt;Spot&gt; ss = new Stack&lt;Spot&gt;();
      Spot topPost, nextPost;
  
      allOld();
  
      ss.push(b);
      markOld(b);
  
      topPost = ss.peek();
      while (!ss.empty() &amp;&amp; (topPost.compareTo(e) != 0)) {
  
          nextPost = getNextSpot(topPost);
          if (nextPost == null) {
              ss.pop();
          } else {
              ss.push(nextPost);
              markOld(nextPost);
          }
          topPost = ss.peek();
      }
      if (ss.empty()) {
          return false;
      } else {
          return true;
      }
  }
  public void index(int x, int y, int dx, int dy){
      x=array.length;
      y=array[x].length;
      for( int i=0;i &lt;x;i++){
          for(int j =0; j&lt;y;j++){
              if(array[i].get(i))//this should determine if its aninersection and then add to the stack
          }
      }
  }
  </code></pre>
  
  <p>}
  the last method is where i am getting stuck. I dont know how to get the specific index values. I guess i can enter them manually but I am sure there is an easier way. Please comment if need more context on the problem and Thanks again.</p>