How to input relation into two dimensional array?
<p>I have a problem in my project math. </p>

<p>My project is to write a program that reads a set of elements and its relations. Your input data will be from a text file. (SetRelation).</p>

<p><code>{1,2,3} {(1,1),(2,2),(3,3),(1,2),(1,3),(2,3)}</code></p>

<p>I have no problem reading the text file into the program but I'm stuck when I want to try to put the relation into the two dimensional array.</p>

<p>For example: <code>{(1,1),(2,2),(3,3),(1,2),(1,3),(2,3)}</code></p>

<p>The two dimensional array would have to be like this:</p>

<pre><code>col[0][1][2]
[0] 1  1  1
[1]    1  1
[2]       1
</code></pre>

<p>I don't know how to set one into two dimensional array because there are various relations in the text file.</p>

<p>This is my coding.</p>

<pre><code>import javax.swing.*;
       import java.util.ArrayList;
       import java.io.*;
       import java.util.StringTokenizer;
       import java.lang.*;
       import java.util.*;

       public class tests 
       {
          public static int s1[][];
          public static int s2[][];
          public static int s3[][];
          public static int s4[][];
          public static int s5[][];
          public static int s6[][];
          public static int s7[][];
          public static int s8[][];
          public static int s9[][];
          public static int s10[][];

    public static void main(String[] args) throws IOException, FileNotFoundException
    {
        BufferedReader infile = null; 

        ArrayList arr1 = new ArrayList();
        ArrayList arr2 = new ArrayList(); 
        ArrayList arr3 = new ArrayList();
        ArrayList arr4 = new ArrayList();
        try
        {
              infile = new BufferedReader (new FileReader ("numbers.txt"));

              String indata = null;

              while ((indata = infile.readLine())!= null) 
              {
                     StringTokenizer st = new StringTokenizer(indata," ");
                     String set = st.nextToken();
                     arr1.add(set);
                     String relation = st.nextToken();
                     arr2.add(relation);
              } 

              for(int i =0; i &lt; arr2.size(); i++)
              {
                  String r = arr2.get(i).toString();
                  String result = r.replaceAll("[{}(),; ]", "");
                  arr3.add(result);
              }

              for(int i = 0; i &lt; arr3.size(); i++)
              {
                  System.out.println(arr3.get(i).toString());
              }

              for(int i =0; i &lt; arr1.size(); i++)
              {
                  String s = arr1.get(i).toString();
                  String result = s.replaceAll("[{}(),; ]", "");
                  arr4.add(result);  
              }

              int set1 = Integer.parseInt(arr4.get(0).toString());
              String ss1 = arr4.get(0).toString();
              int a = ss1.length();
              s1 = new int[a][a];
              int sA[][];
              /*for(int row=1;row&lt; a;row++)
              {
                  for(int col=0;col &lt; a;col++)
                  {
                      sA = new int[row][col];
                      int firstNo = Integer.parseInt(arr3.get(row).toString());
                      int secondNo = Integer.parseInt(arr3.get(col).toString());
                      sA = new int [firstNo][ secondNo] ;  

                      System.out.print(sA);
                  }
                  System.out.println();
              }*/
              char arrA;
              char indOdd=' ',indEven=' ';
                 char[] cArr = arr3.get(0).toString().toCharArray();
                 //System.out.println(arr3.get(0).toString().length());
                 int l = arr3.get(0).toString().length();
                 int arr10[][] = new int[(l/2)][2];

                    for(int i=0;i&lt; 2;i++)
                    {
                        for(int row = 0; row &lt; (l/2);row++)
                        {
                            for(int gh = 0;gh &lt; l;gh++)
                            {
                                if(i%2==0)
                                {
                                indEven = cArr[gh];
                                System.out.println(indEven);
                                arr10[row][i] = indEven;
                                //System.out.println(arr10[row][i]);
                                //row++;
                            }
                            else
                            {
                                indOdd = cArr[gh+1];
                                System.out.println(indOdd);
                                arr10[row][i] = indOdd;
                                //row++;
                            }
                         }
                        }
                            //arr10 = new int[indOdd][indEven];
                            //System.out.println(arr10);
                    }         

        }
        catch (FileNotFoundException fnfe)
        {
               System.out.println("File not found");
        }
        catch (IOException ioe)
        {
               System.out.println(ioe.getMessage());
        }
        catch (Exception e)
        {
               System.out.println(e.getMessage());
        }

        infile.close();


    }
}
</code></pre>

<p>But I'm stuck how to set one into the two dimensional array if the relation is <code>{(a,b),(a,c),(b,a),(b,c),(c,c)};</code> and <code>{(33,33),(45,45),(67,67),(77,77),(78,78)};</code></p>
