What is the size of an array after redefining its variable?

  • Thread starter Catalina Cuellar
  • Start date

Catalina Cuellar

In Java, I have an existing array of length N assigned to a variable called st. If I create a new array of the same type with size N + k called newSt. What is the result of newSt = st? Will newSt have the contents of st and empty space or will newSt reduce its length to st's length?

Object[] st = new Object[20];

// st is filled

Object[] newSt = new Object[40];

newSt = st;

Continue reading...