title: Two Dimensional Array Grid Player Movement Java
body: <p>Could somebody please help me solve the player movement of my 2d array grid.I'm able to print out the grid fine and display it. I'm also able to print out the player on the grid. I'm only having a hard time moving the player to the next position. I've tried looking at C++ code to try and replicate it but it hasn't been going well. </p>
  
  <pre><code>import java.util.Scanner;
  import java.util.Random;
  public class Components 
  {
  public Components()
  {       
      Graph();
  }
  
  void Graph()
  {
      int Row,Col,Num1,Num2;
      int p1 = 0;
      int p2 = 0;
      char Move;
      boolean Running = true;
      Scanner input = new Scanner(System.in);
      //Random random = new Random();
      System.out.println("Please Enter The Number Of Row:");
      Row = input.nextInt();
      System.out.println("Please Enter The Number Of Columns:");
      Col = input.nextInt();
      int Array[][] = new int [Row][Col];
      //Num1 = random.nextInt(Row) + 1;
      //Num2 = random.nextInt(Col) + 1;
      for(int i=0;i&lt;Row;i++)
      {
      for(int x=0;x&lt;Col;x++)
      {
      Array[i][x] = 0;
      Array[p1][p2] = 1;
      }
      }
      for(int i=0;i&lt;Row;i++)
      {
      for(int x=0;x&lt;Col;x++)
      {
      System.out.print(Array[i][x] + "\t");
      }
      System.out.println();
      }
      while(Running)
      {
      Move = input.next().charAt(0);
      switch(Move)
      {
      case 'w':
      case 'W':
      Array[p1][p2] = 0;
      Array[p1+=1][p2] = 1;
      break;
      case 's':
      case 'S':
      Array[p1][p2] = 0;
      Array[p1-=1][p2] = 1;
      break;
      case 'd':
      case 'D':
      Array[p1][p2] = 0;
      Array[p1][p2+=1] = 1;
      break;
      case 'a':
      case 'A':
      Array[p1][p2] = 0;
      Array[p1][p2-=1] = 1;
      break;
      case 'l':
      case 'L':
      Running = false;
      input.close();
      break;
      default:
      System.out.println("Please Press Proper Keys!");
      break;
      }
      }
      }
      }
  
    public class Main {
  
    public static void main(String[] args) {
  
    new Components();
     }
  
     }
  </code></pre>