2019-07-17 10:05:56 1534浏览
今天千锋扣丁学堂Java培训老师给大家分享一篇关于从java面试题了解模糊数组的详细介绍,首先数组用来存储一系列的数据项,其中的每一项具有相同的基本数据类型、类或相同的父类。通过使用数组,可以在很大程度上缩短和简化程序代码,从而提高应用程序的效率。下面我们一起来看一下吧。
	
	
a[i]_address = base_address + i * data_type_size
/** * Default initial capacity. */ private static final int DEFAULT_CAPACITY = 10;
/**
* Increases the capacity to ensure that it can hold at least the
* number of elements specified by the minimum capacity argument.
*
* @param minCapacity the desired minimum capacity
*/
private void grow(int minCapacity) {
// overflow-conscious code
int oldCapacity = elementData.length;
int newCapacity = oldCapacity + (oldCapacity >> 1);
if (newCapacity - minCapacity < 0)
newCapacity = minCapacity;
if (newCapacity - MAX_ARRAY_SIZE > 0)
newCapacity = hugeCapacity(minCapacity);
// minCapacity is usually close to size, so this is a win:
elementData = Arrays.copyOf(elementData, newCapacity);
}
public static void main(String[] args) {
int a=10;
int b=20;
System.out.println("a="+a+" b="+b);
change(a, b);
System.out.println("a="+a+" b="+b);
}
public static void change(int a,int b) {
a=b;
b=a+b;
System.out.println("a="+a+" b="+b);
}
a=10 b=20 a=20 b=40 a=10 b=20
public static void main(String[] args) {
int[] arr = {9,3,4,5,6};
change(arr);
System.out.println(arr[1]);
}
public static void change(int[] arr) {
for(int i=0;i<arr.length;i++) {
if(arr[i] % 3 == 0) {
arr[i]*=2;
}
}
}
	
	
                        
	
【关注微信公众号获取更多学习资料】 【扫码进入JavaEE/微服务VIP免费公开课】