title: Java calling array from another class
body: <p>I am trying to store an <code>arrayList</code> of objects to a text file created from the array <code>ipvalue[]</code> which is instantiated in another class. My problem is that whenever i try to load the array from the <code>Mainframe</code> class to the <code>Arraystorage</code> class, it displays the entire array as null outputs. I guess the problem is that the array data is generated within the Mainframe method, and when I call the array from another class it simply takes the array as it is initialized. So my question is how do I how can I access the array after it is assigned value rather then when it is initialized.</p>
  
  <pre><code>new String[50] 
  mainframe class:
  
  
  
  public class Mainframe extends javax.swing.JFrame {
  static int ipcounter = 0;
  public static String[] ipvalue = new String [50];
  
  
  /**
   * String a[]Creates new form Mainframe
   */
      public Mainframe() {
           try {
          initComponents();
          this.setLocation(500,250);
          Nettest.main(null);
          Display.setText(Nettest.indicator);
          Arraystorage.main(null);
          Path path = Paths.get("ipcounter.txt");
  
           File file = new File("ipcounter.txt");
  
  
           FileReader in = new FileReader("ipcounter.txt");
          BufferedReader br = new BufferedReader(in);
  
          readline = Integer.parseInt(br.readLine()); 
          in.close();
          ipcounter = readline;
  
           if(ip.tracker.Nettest.status == true){
           ipvalue[ipcounter] = Readipfromurl.inputLine;
         //  crosscheck();
  
          Writer writer = null;
           writer = new BufferedWriter(new OutputStreamWriter(
           new FileOutputStream("ipcounter.txt"), "utf-8"));
            writer.write(String.valueOf(ipcounter+1));
  
            writer.close();
           System.out.println(ipvalue[ipcounter]);
            ipcounter++;
  
  
  arraystorage class:
  
  
  public class Arraystorage implements Serializable{
     public static void main(String[] args) throws 
   ClassNotFoundException { 
  
     ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
    for (int i=0; i&lt;50;i++){
    list.add(Mainframe.ipvalue[i]);}
     try {
         PrintWriter out = new PrintWriter(new BufferedWriter(new 
    FileWriter("data.txt")));
     for( int x = 0; x &lt; list.size(); x++)
   {
   out.println(list.get(x));
   }
  
     out.close();
  
  
     } catch (IOException ex) {
  
   Logger.getLogger(Arraystorage.class.getName()).log(Level.SEVERE, 
  null, ex);
     }
  </code></pre>