javaÊý¾Ý½á¹¹Ö®¶Ñջ˼Ï루Êý×飩
ºÜ¶àʱºòÊý×é´æÔÚןܴóµÄȱÏÞ£¬Ê×ÏȱØÐëÏÈÉèÖÃÊý×éµÄ³¤¶È£¬µ±É趨ÁËÖ®ºó£¬¾ÍÎÞ·¨¸Ä±äÁË¡£
ÏÂÀ´ÊÇÒ»ÖÖÊý×鳤¶È¶¯Ì¬±ä»¯µÄÒ»ÖÖ·½·¨
package com.yz.mystack;
public class Stack {
Object[] datas;
Integer n=0;
Integer N=1;
public Stack(){
datas=new Object[N];
}
public void push(Object data){
if(n>=N){
N+=2;
Object[] temps=datas;
datas=new Object[N];
for(int i=0;i<temps.length;i++){
datas[i]=temps[i];
}
}
datas[n++]=data;
}
public Object peek(){
return datas[n-1];
}
public Object pop(){
if(--n>=0){
return datas[n];
}
return 0;
}
public static void main(String[] args){
Stack stack=new Stack();
stack.push("aa");
stack.push("bb");
stack.push("cc");
System.out.println(stack.pop());
System.out.println(stack.pop());
System.out.println(stack.pop());
System.out.println(stack.pop());
}
}
Ïà¹ØÎĵµ£º
JavaÓïÑÔµÄÊäÈëÊä³ö¹¦ÄÜÊÇÊ®·ÖÇ¿´ó¶øÁé»îµÄ£¬ÃÀÖв»×ãµÄÊÇ¿´ÉÏÈ¥ÊäÈëÊä³öµÄ´úÂë²¢²»ÊǺܼò½à£¬ÒòΪÄãÍùÍùÐèÒª°ü×°Ðí¶à²»Í¬µÄ¶ÔÏó¡£ÔÚJavaÀà¿âÖУ¬IO²¿·ÖµÄÄÚÈÝÊǺÜÅÓ´óµÄ£¬ÒòΪËüÉæ¼°µÄÁìÓòºÜ¹ã·º:±ê×¼ÊäÈëÊä³ö£¬ÎļþµÄ²Ù×÷£¬ÍøÂçÉϵÄÊý¾ÝÁ÷£¬×Ö·û´®Á÷£¬¶ÔÏóÁ÷£¬zipÎļþÁ÷....±¾ÎĵÄÄ¿µÄÊÇΪ´ó¼Ò×öÒ»¸ö¼òÒªµÄ½éÉÜ¡£
¡¡¡¡Á ......
Êý¾Ý½á¹¹ºÍËã·¨
ðÅÝ£ºÃ¿´Î±È½Ï¶¼¿ÉÕÒ³ö×î´ó»ò×îСµÄ£¬ÓÐÐòµÄÔÚ×îÓÒ±ß
Ñ¡ÔñÅÅÐò£ºÓÐÐòµÄÔÚ×î×ó±ß
²åÈëÅÅÐò£ºËٶȱÈðÅÝ¿ìÒ»±¶£¬±ÈÑ¡ÔñÒ²¿ì¡£
µÝ¹é
µ÷ÓÃ×ÔÉí
ººÅµËþÎÊÌ⣺
/**
* @ººÅµËþµÄÎÊÌâ
*/
......
ͨ³£Çé¿öÏ£¬ÎÒÃÇÔÚдһ¸öÀàʱ£¬Ò»°ã»á¸³ÓèËüÒ»¸ö»ò¼¸¸öpublicµÄ¹¹Ô캯Êý£¬ÈÃÍⲿ³ÌÐòÄܹ»´´½¨¶ÔÏó.¡¡È»¶ø£¬ÔÚeffective¡¡java ÖУ¬´ÓÁíÒ»¸ö½Ç¶È¸æ½ëÎÒÃÇÔÚʹÓÃpublicµÄ¹¹Ô캯Êýǰ£¬ÏÈ¿¼ÂÇÓÃpublic µÄ¾²Ì¬º¯ÊýÀ´´´½¨¶ÔÏó.¡¡
ÆäÓŵãÈçÏ£º
£±.¡¡Ò»¸ö¾²Ì¬µÄ¹¤³§º¯Êý£¬¿ÉÒÔÈ¡²»Í¬µÄÃû×Ö.¡¡¶ø¹¹Ô캯ÊýµÄÃû×ÖÖ»ÄÜÓëÀàͬÃû.¡¡
......
Java Reflect±àд ͨÓÃÊý×éÀ©Õ¹Àà
package com.accp.array;
import java.lang.reflect.Array;
public class GrowArrayTest {
public static void main(String[] args) {
Integer[] array = {1,2,3,4}; //ͨÓÃÀ©Õ¹
arrayPrint(arra ......