JavaÊý¾Ý½á¹¹ºÍËã·¨ Õ»Óë¶ÓÁÐ
(1)Õ»
package ChapterOne;
public class Stack {
//Õ»Êý×é
long stackArr[];
//Õ»µÄ´óС
int maxSize;
//Õ»µÄ¶¥²¿
int top;
//³õʼ»¯Ò»¸ö´óСΪsizeµÄÕ»
public Stack(int size){
maxSize = size;
stackArr = new long[size];
top = -1;
}
//³öÕ»²Ù×÷
public long pop(){
return stackArr[top--];
}
//½øÕ»²Ù×÷
public void push(long value){
stackArr[++top] = value;
}
//ÅжÏÕ»ÊÇ·ñΪ¿Õ
public boolean isEmpty(){
return top == -1;
}
//ÅжÏÕ»ÊÇ·ñÒÑÂú
public boolean isFull(){
return top == maxSize-1;
}
//ȡջ¶¥ÔªËØ
public long peek(){
return stackArr[top];
}
public static void main(String[] args) {
Stack stack = new Stack(10);
while(!stack.isFull()){
long v = (long) (Math.random()*100);
stack.push(v);
System.out.print(v+" ");
}
System.out.println();
while(!stack.isEmpty()){
long topValue = stack.pop();
System.out.print(topValue+" ");
}
System.out.println();
}
}
(2)¶ÓÁÐ
package ChapterOne;
public class Queue {
//¶ÓÁÐÊý×é
private long queueArr[];
//¶ÓÁеÄǰ¶Ëϱê
private int front;
//¶ÓÁеÄβ¶Ëϱê
private int rear;
//¶ÓÁеĴóС
private int maxSize;
//¶ÓÁÐÖÐÔªËØµÄ¸öÊý
private int nItems;
//³õʼ»¯Ò»¸ö´óСΪsizeµÄ¶ÓÁÐ
public Queue(int size){
queueArr = new long[size];
maxSize = size;
front = 0;
rear = -1;
nItems = 0;
}
//²åÈë²Ù×÷
public void insert(long value){
//¶ÓÁÐÒÑÂú
if(rear == maxSize-1)
rear = -1;
queueArr[++rear] = value;
nItems++;
}
//ɾ³ý²Ù×÷
public long remove(){
long temp = queueArr[front++];
if(front == maxSize)
front = 0;
nItems--;
return temp;
}
//·µ»Ø¶ÓÁеÚÒ»¸öÔªËØ
public long peakFront(){
return queueArr[front];
}
//ÅжÏÊÇ·ñΪ¿Õ
public boolean isEmpty(){
return nItems == 0;
}
//ÅжÏÊÇ·ñÒÑÂú
public boolean isFull(){
return nItems == maxSize;
}
//·µ»Ø¶ÓÁÐÖÐÔªËØµÄ¸öÊý
public int size(){
return nItems;
}
public void print(){
for(int i =
Ïà¹ØÎĵµ£º
ÉèÖÃ×¢ÊÍÄ£°åµÄÈë¿Ú£º Window->Preference->Java->Code Style->Code Template È»ºóÕ¹¿ªComments½Úµã¾ÍÊÇËùÓÐÐèÉèÖÃ×¢Ê͵ÄÔªËØÀ²¡£ÏÖ¾Íÿһ¸öÔªËØÖðÒ»½éÉÜ£º
Îļþ(Files)×¢ÊͱêÇ©£º
/**
* @Title: ${file_name}
* @Package ${package_name}
* @Description: ${todo}(ÓÃÒ»¾ä»°ÃèÊö¸ÃÎļ ......
JavaỊ̈߳ºÐÂÌØÕ÷-Ìõ¼þ±äÁ¿
Ìõ¼þ±äÁ¿ÊÇJava5Ïß³ÌÖкÜÖØÒªµÄÒ»¸ö¸ÅÄ¹ËÃû˼Ò壬Ìõ¼þ±äÁ¿¾ÍÊDZíʾÌõ¼þµÄÒ»ÖÖ±äÁ¿¡£µ«ÊDZØÐë˵Ã÷£¬ÕâÀïµÄÌõ¼þÊÇûÓÐʵ¼Êº¬ÒåµÄ£¬½ö½öÊǸö±ê¼Ç¶øÒÑ£¬²¢ÇÒÌõ¼þµÄº¬ÒåÍùÍùͨ¹ý´úÂëÀ´¸³ÓèÆäº¬Òå¡£
ÕâÀïµÄÌõ¼þºÍÆÕͨÒâÒåÉϵÄÌõ¼þ±í´ïʽÓÐ×ÅÌìÈÀÖ®±ð¡£
Ìõ¼þ±äÁ¿¶¼ÊµÏÖÁË ......
°æÈ¨ÉùÃ÷£º×ªÔØÊ±ÇëÒÔ³¬Á´½ÓÐÎʽ±êÃ÷ÎÄÕÂÔʼ³ö´¦ºÍ×÷ÕßÐÅÏ¢¼°±¾ÉùÃ÷
http://as112255.blogbus.com/logs/38662785.html
package com.softeem.jbs.lesson4;
import java.util.Random;
/**
* ÅÅÐò²âÊÔÀà
*
* ÅÅÐòËã·¨µÄ·ÖÀàÈçÏ£º
* 1.²åÈëÅÅÐò£¨Ö±½Ó²åÈëÅÅÐò¡¢ÕÛ°ë²åÈëÅÅÐ ......
synchronized£º ͬ²½µÄ
synchronizedÔÚ²Ù×÷ÉÏÓÐÁ½ÖÖÓ°Ïì¶ÔÏóµÄÇé¿ö£º
1) ÔÚij¸ö¶ÔÏóʵÀýÄÚ£¬synchronized method(){}¿ÉÒÔ·ÀÖ¹¶à¸öÏß³Ìͬʱ·ÃÎÊÕâ¸ö¶ÔÏóµÄsynchronized·½·¨£¨Èç¹ûÒ»¸ö¶ÔÏóÓжà¸ösynchronized·½·¨£¬Ö»ÒªÒ»¸öÏ̷߳ÃÎÊÁËÆäÖеÄÒ»¸ösynchronized·½·¨£¬ÆäËüÏ̲߳»ÄÜͬʱ·ÃÎÊÕâ¸ö¶ÔÏóÖÐÈκÎÒ»¸ösynchronized·½·¨£ ......
Android_1.0_eBook_by_tom_kao_2008_10_15.pdf
¡¶AndroidÓ¦Óÿò¼ÜÔÀíÓë³ÌÐòÉè¼Æ36¼¼¡·
±¾書ÍêÕû範例³Ìʽ碼請µ½網Õ¾ÏÂ載:
www.misoo1.com »ò tom-kao.blogspot.com
¸ß煥ÌÃ Öø(2008 年10 ÔµÚÈý°æ)
misoo.tw@gmail.com
&n ......