title: How to multiply 2 ArrayLists together?
body: <p>My question is, how can I multiply two ArrayList(s) together? What I am trying to do is import two separate files (which contain 2d arrays) and put them into separate arraylists. From there I am trying to multiply these two array lists together and then have my output file be a 2d array of the the product of the inputted 2d arrays. In Short, I have two input files (each file is a separate two dimensional array) and I must take these two input files, and multiply them together. My output file should be a single 2d array.</p>
  
  <p>So far my code looks like:</p>
  
  <pre><code>package Matrix;
  
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.PrintWriter;
  import java.util.ArrayList;
  import java.util.Scanner;
  
  public class Matrix {
  
  public static void multiply(File input_file1, File input_file2, File output_file) {
  
  
  
      try {
          Scanner scanner = new Scanner(input_file1);
          PrintWriter printer = new PrintWriter(output_file);
          ArrayList&lt;Integer&gt; file1 = new ArrayList&lt;Integer&gt;();
          while (scanner.hasNextInt()){
              file1.add(scanner.nextInt());
          }
          scanner.close();
          printer.close();
  
      }catch (FileNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
      try {
          Scanner scanner = new Scanner(input_file1);
          PrintWriter printer = new PrintWriter(output_file);
          ArrayList&lt;Integer&gt; file2 = new ArrayList&lt;Integer&gt;();
          while (scanner.hasNextInt()){
              file2.add(scanner.nextInt());
          }
          scanner.close();
          printer.close();
      }catch (FileNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
  }
  
  }
  </code></pre>