Take the 2-minute tour ×  I already asked this question and I
got additional question about using class I made myself. see
code below.    import java.util.*;      class Pair{       int
toWhere;       int weight;      public class Test{       public
static void main(String[] args){         ArrayList[] arr = new
ArrayList[2];         Pair p = new Pair();            arr[i] =
new ArrayList<Pair>();          p.toWhere = 1;         p.weight
= 2;         System.out.println(p); // gives me Pair@525483cd
System.out.println(arr[0].get(0)); // gives me exactly the same,
Pair@525483cd         System.out.println(p.toWhere); // gives me
no error, and is 1
System.out.println(arr[0].get(0).toWhere); // gives me an error
my question is this. values of p and arr[0].get(0) (which is
address? I guess) is the same. but why does p.toWhere give me
the accurate value and arr[0].get(0).toWhere does not?
share|improve this question May be you should use this instead
ArrayList<Pair>[] –  Nishant Aug 1 '11 at 4:49 add