title: Return/print array
body: <p>I have a problem with return an array.</p>
  
  <pre><code>package iterators;
  
  import java.util.*;
  import java.io.*;
  
  
  public class Nic {
      String[] abel() throws IOException {
          int i = 0;
          BufferedReader wczytaj = new BufferedReader(new FileReader("filmy.txt"));
          StringBuilder sb = new StringBuilder();
          String tekst = wczytaj.readLine();
          while (tekst != null) {
              sb.append(tekst);
              sb.append("\n");
              tekst = wczytaj.readLine();
          }
          String calosc = sb.toString();
          String film = calosc;
          String znak = ",";
          String[] tab;
          tab = film.split(znak);
          for (i = 0; i &lt; tab.length; i++) {
              System.out.println("listusia: " + i + " " + tab[i]);
          }
          List&lt;String&gt; list = Arrays.asList(tab);
          Collections.reverse(list);
          tab = (String[]) list.toArray();
          for (i = 0; i &lt; tab.length; i++) {
              System.out.println(tab[i]);
          }
          return tab;
      }
  }
  </code></pre>
  
  <p>I would like to return an array, which is printed here:</p>
  
  <pre><code>for(i=0;i&lt;tab.length;i++){
      System.out.println(tab[i]);
  }
  </code></pre>
  
  <p>but I have problem. It's not possible to return tab[i], because it gets me an error "Incompatible types". I need this array to other operations. Could anyone help me?</p>
  
  <p>This is my code after changes:</p>
  
  <pre><code>package iterators;
  import java.util.*;
  import java.io.*;
  public class Nic{
          String abel() throws IOException{
              int i=0;
              BufferedReader wczytaj = new BufferedReader(new FileReader("filmy.txt"));
              StringBuilder sb=new StringBuilder();
              String tekst=wczytaj.readLine();
              while (tekst!=null) {
                  sb.append(tekst);
                  sb.append("\n");
                  tekst=wczytaj.readLine();
              }
              String calosc=sb.toString();
              String film=calosc;
              String znak=",";
              String[]tab=new String[301];
              tab=film.split(znak);
              for(i=0;i&lt;tab.length;i++){ 
                  //System.out.println("listusia: "+i+" "+tab[i]);
              }
              List&lt;String&gt; list=Arrays.asList(tab);
              Collections.reverse(list);
              tab = (String[]) list.toArray();
              for(i=0;i&lt;tab.length;i++){
                  //System.out.println(tab[i]);
              }
              return tab[i];
          }
      }
  </code></pre>