title: Using an array from one function in another function in same fragment
body: <p>Im new to java and attempting to use <code>sampleTitles</code> from one function and use in another function. The data  in <code>sampleTitles</code> is dynamic and drawn from retrofit</p>
  <p>Fragment.java</p>
  <pre><code>@BindView(R.id.customCarouselView) CarouselView customCarouselView; //butterknife
  
  double[] sampleVotes = {
      8.9,4.2,
  };
  
  @Override
  public void onCreate (@Nullable Bundle savedInstanceState) {
      super.onCreate (savedInstanceState);
      
      connect();
  }
  
  private void connect() {
  
      //this array not passed to setViewListener 
      String[] sampleTitles = {
                  &quot;Test 1&quot;,
                  &quot;Test 2&quot;,
      };
                          
      customCarouselView.setViewListener(viewListener);
  }
  
  // To set custom views
  ViewListener viewListener = new ViewListener() {
      @Override
      public View setViewForPosition(int position) {
  
          View customView = getLayoutInflater().inflate(R.layout.view_custom, null);
  
          TextView labelTextView = customView.findViewById(R.id.labelTextView);
          labelTextView.setText(sampleTitles[position]);  //want to use sampleTitles here from 
          connect(); function               
  
          return customView;
      }
  };
  </code></pre>