数组扩容代码:
package cn.tedu.demo;
import java.util.Arrays;
public class Demo {
public static void main(String[] args) {
//数组扩容
int[] nums = {1,2,3,5,6,7,9};
int[] arr = Arrays.copyOf(nums,nums.length*2);
System.out.println(Arrays.toString(arr));
}
}
输出:[1, 2, 3, 5, 6, 7, 9, 0, 0, 0, 0, 0, 0, 0]

数组扩容代码图:数组扩容

相关文章:

  • 2022-12-23
  • 2021-06-09
  • 2022-02-14
  • 2021-07-26
  • 2021-11-22
  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-04-23
  • 2021-05-12
  • 2022-12-23
  • 2022-12-23
  • 2021-05-21
  • 2021-08-15
相关资源
相似解决方案