title: (7,4) Hamming code using strings
body: <p>I am trying to use a (7,4) hamming code to encode and decode a string. I started to do it with bits only and I think it's working. However, I'm not sure how to involve strings in the situation. One of my friends told me to use map dictionary but I'm not sure how to do so.</p>
  
  <p>Can someone help me with this?</p>
  
  <p>Here is what I've done so far:</p>
  
  <pre><code>import java.util.*;
  class Hamming
   {
  public static void main(String arg[])
   {
  Scanner sc = new Scanner(System.in);
  
  int dataCode[] = new int[7];
  int parity[] = new int[4];
  int comCode[] = new int[11];
  int receive[] = new int[11];
  int parityR[] = new int[4];
  int receiveD[] = new int[7];
  int syndrome[] = new int[4];
  int check;
  
  System.out.println("Enter the data code (7-bits): ");
  for(int i=0;i&lt;7;i++)
    dataCode[i]=sc.nextInt();
  
  
  parity[0] = dataCode[0]^dataCode[1]^dataCode[3]^dataCode[4]^dataCode[6];
  parity[1] = dataCode[0]^dataCode[2]^dataCode[3]^dataCode[5]^dataCode[6];
  parity[2] = dataCode[1]^dataCode[2]^dataCode[3];
  parity[3] = dataCode[4]^dataCode[5]^dataCode[6];
  
  
  System.out.print("\nCode Word is ");
  
  comCode[0] = parity[0];  
  comCode[1] = parity[1];  
  comCode[2] = dataCode[0];
  comCode[3] = parity[2];  
  comCode[4] = dataCode[1];  
  comCode[5] = dataCode[2];
  comCode[6] = dataCode[3];  
  comCode[7] = parity[3];  
  comCode[8] = dataCode[4];
  comCode[9] = dataCode[5];  
  comCode[10] = dataCode[6];
  
  System.out.println();
  for(int i=0; i&lt;11;i++)
    System.out.print(comCode[i]+ " ");
  
  System.out.println("\n\nEnter codeword which you received: ");
  for(int i=0;i&lt;11;i++)
    receive[i] = sc.nextInt();
  
  parityR[0] = receive[0];
  parityR[1] = receive[1];
  receiveD[0] = receive[2];
  parityR[2] = receive[3];
  receiveD[1] = receive[4];
  receiveD[2] = receive[5];
  receiveD[3] = receive[6];
  parityR[3] = receive[7];
  receiveD[4] = receive[8];
  receiveD[5] = receive[9];
  receiveD[6] = receive[10];
  
  
  syndrome[0] = parityR[0] ^ receiveD[0] ^ receiveD[1] ^ receiveD[3] ^ receiveD[4] ^ receiveD[6];
  syndrome[1] = parityR[1] ^ receiveD[0] ^ receiveD[2] ^ receiveD[3] ^ receiveD[5] ^ receiveD[6];
  syndrome[2] = parityR[2] ^ receiveD[1] ^ receiveD[2] ^ receiveD[3];
  syndrome[3] = parityR[3] ^ receiveD[4] ^ receiveD[5] ^ receiveD[6];
  
  check = (syndrome[0]*1) + (syndrome[1]*2) + (syndrome[2]*4) + (syndrome[3]*8);
  
  System.out.print("\nResult: ");
  if(check == 0)
    System.out.println("\nNo error");
  else
  {
    System.out.println("\nError is at " + check);
    if(receive[check - 1] == 0)
      receive[check - 1] = 1;
    else
      receive[check - 1]=0;
  }
  
  System.out.println("Code word after Correction: ");
  for(int i=0;i&lt;11;i++)
    System.out.print(receive[i]+" ");
  
  }
  }
  </code></pre>
  
  <p>can someone please tell me how should I start doing it or looking at it? 
  Thanks in advance</p>