title: Is it possible to store a variable from nested void Override method and return it?
body: <p>I define global variable name <code>String str[]</code>. There is a method name getMessageArray which the type of that is <code>String[]</code> inside this method , there is another override void method from a library (jar) file. my intent is to return String array which is populated in override method , from <code>getMessageArray</code> but with the code bellow I get <code>null</code> when I debug. is there technically any way in java to fix the issue?
  I need this for some purpose of using firebase.</p>
  
  <pre><code>public String[] getMessageArray(){
          Firebase ref = new Firebase(firebaseUrl);
          ref.addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
                  long strLength;
                  strLength = dataSnapshot.getChildrenCount();
                  str = new String[(int) strLength];
                  int i = 0;
                  for (DataSnapshot iterator : dataSnapshot.getChildren()) {
                   str[i]=iterator.child("message").getValue().toString();
                      i++;
                  }
                  }
              @Override
              public void onCancelled(FirebaseError firebaseError) {
                  System.out.println("The read failed: " + firebaseError.getMessage());
              }
          });
         return str;
  }
  </code></pre>
  
  <p>my question is how to store populated data , and return it as array with value in example above</p>