• Saves Valuable Time
  • Trusted Accuracy since 2004
  • 15-Day Money-Back Guarantee

Java Equivalent to VB ReDim Preserve

Resizing arrays while preserving the existing contents is easily done in VB using ReDim Preserve.  In Java, you have other alternatives:

VB Java
Dim YourArray() As Integer
ReDim Preserve YourArray(i)
int[] YourArray;
int[] temp = new int[i + 1];
if (YourArray != null)
    System.arraycopy(YourArray, 0, temp, 0, Math.min(YourArray.length, temp.length));
YourArray = temp;

Use VB to Java Converter to convert from VB to Java.     

Additional resource: VB.NET and Java Equivalents

Copyright © 2004 – 2021 Tangible Software Solutions, Inc.