JAVA»ñµÃÒ»¸öÊý×éµÄÖ¸¶¨³¤¶ÈµÄÅÅÁÐ
import java.util.Stack;
/**
* JAVA»ñµÃÒ»¸öÊý×éµÄÖ¸¶¨³¤¶ÈµÄÅÅÁÐ×éºÏ¡£<br>
*
* @author JAVAÊÀ¼ÍÍø(java2000.net, laozizhu.com)
*/
public class TestSequenceAll {
public static void main(String[] args) {
TestSequenceAll t = new TestSequenceAll();
Object[] arr = { 1, 2, 3 };
// Ñ»·»ñµÃÿ¸ö³¤¶ÈµÄÅÅÁÐ×éºÏ
for (int num = 1; num <= arr.length; num++) {
t.getSequence(arr, 0, num);
}
}
// ´æ´¢½á¹ûµÄ¶ÑÕ»
private Stack<Object> stack = new Stack<Object>();
/**
* »ñµÃÖ¸¶¨Êý×é´ÓÖ¸¶¨¿ªÊ¼µÄÖ¸¶¨ÊýÁ¿µÄÊý¾Ý×éºÏ<br>
*
* @param arr Ö¸¶¨µÄÊý×é
* @param begin ¿ªÊ¼Î»ÖÃ
* @param num »ñµÃµÄÊýÁ¿
*/
public void getSequence(Object[] arr, int begin, int num) {
if (num == 0) {
System.out.println(stack); // ÕÒµ½Ò»¸ö½á¹û
} else {
// Ñ»·Ã¿¸ö¿ÉÓõÄÔªËØ
for (int i = begin; i < arr.length; i++) {
// µ±Ç°Î»ÖÃÊý¾Ý·ÅÈë½á¹û¶ÑÕ»
stack.push(arr[i]);
// ½«µ±Ç°Êý¾ÝÓëÆðʼλÖÃÊý¾Ý½»»»
swap(arr, begin, i);
// ´ÓÏÂÒ»¸öλÖòéÕÒÆäÓàµÄ×éºÏ
getSequence(arr, begin + 1, num - 1);
// ½»»»»ØÀ´
swap(arr, begin, i);
// È¥³ýµ±Ç°Êý¾Ý
stack.pop();
}
}
}
/**
* ½»»»2¸öÊý×éµÄÔªËØ
*
* @param arr Êý×é
* @param from λÖÃ1
* @param to λÖÃ2
*/
public static void swap(Object[] arr, int from, int to) {
if (from == to) {
return;
}
Object tmp = arr[from];
arr[from] = arr[to];
arr[to] = tmp;
}
}
from:http://peterliuye.javaeye.com/blog/364395
Ïà¹ØÎĵµ£º
ÏßÐÔ±í£¬Á´±í£¬¼¯ºÏ£¬¹þÏ£±íÊdz£ÓõÄÊý¾Ý½á¹¹£¬ÔÚ½øÐÐJava¿ª·¢Ê±£¬JDKÒѾΪÎÒÃÇÌṩÁËһϵÁÐÏàÓ¦µÄÀàÀ´ÊµÏÖ»ù±¾µÄÊý¾Ý½á¹¹¡£ÕâЩÀà¾ùÔÚjava.util°üÖС£
Collection
©ÀList
©¦©ÀLinkedList
©¦©ÀArrayList
©¦©¸Vector
©¦¡¡©¸Stack
©¸Set
Map
©ÀHashtable
©ÀHashMap
©¸WeakHashMap
Ö÷Òª·ÖΪÁ½¸ö·ÖÖ§£º
Collectio ......
×¢£ºwait notify ¶¼ÊÇObjectµÄ·½·¨
ͬ²½£¨×èÈû£© £ºÊÇÒ»ÖÖ·ÀÖ¹¶Ô¹²Ïí×ÊÔ´·ÃÎʵ¼ÖµÄÊý¾Ý²»Ò»ÖµÄÒ»ÖÖģʽ¡£
ÏêϸÇë²Î¿´²Ù×÷ϵͳ¡£
ÔÚJavaÖУ¬ÓÉÓÚ¶Ô¶àÏ̵߳ÄÖ§³Ö£¬¶Ôͬ²½µÄ¿ØÖÆÖ÷Ҫͨ¹ýÒÔϼ¸¸ö·½·¨£¬synchronized£¬ºÍwait(),notify()ºÍnotifyAll(),ÏÂÃæ½øÐÐÒ»Ò»µÄ½²½â£º
A¹Ø¼ü×Ösynchronized
ÿ¸öjava¶Ô ......
Java¶ÁÈ¡PropertiesÎļþµÄÁùÖÖ·½·¨
Java¶ÁÈ¡propertiesÎļþ
ʹÓÃJ2SE API¶ÁÈ¡PropertiesÎļþµÄÁùÖÖ·½·¨
1¡£Ê¹ÓÃjava.util.PropertiesÀàµÄload()·½·¨
ʾÀý£º InputStream in = lnew BufferedInputStream(new FileInputStream(name));
Properties p = new Properties();
p.load(in);
2¡£Ê¹ÓÃjava.util.ResourceBundleÀ ......
1.»ù±¾¸ÅÄîµÄÀí½â
¡¡¡¡¾ø¶Ô·¾¶£º¾ø¶Ô·¾¶¾ÍÊÇÄãµÄÖ÷Ò³ÉϵÄÎļþ»òĿ¼ÔÚÓ²ÅÌÉÏÕæÕýµÄ·¾¶£¬(URLºÍÎïÀí·¾¶)ÀýÈ磺
C:\xyz\test.txt ´ú±íÁËtest.txtÎļþµÄ¾ø¶Ô·¾¶¡£http://www.sun.com/index.htmÒ²´ú±íÁËÒ»¸öURL¾ø¶Ô·¾¶¡£
¡¡¡¡Ïà¶Ô·¾¶£ºÏà¶ÔÓëij¸ö»ù׼Ŀ¼µÄ·¾¶¡£°üº¬WebµÄÏà¶Ô·¾¶£¨HTMLÖеÄÏà¶ÔĿ¼£©£¬ÀýÈ磺ÔÚSer ......
JavaµÄºËÐÄAPIÊǷdz£ÅÓ´óµÄ,Õâ¸ø¿ª·¢ÕßÀ´Ëµ´øÀ´Á˺ܴóµÄ·½±ã£¬¾³£ÈËÓÐÆÀÂÛ,javaÈóÌÐòÔ±±äɵ¡£
µ«ÊÇһЩÄÚÈÝÎÒÈÏΪÊDZØÐëÕÆÎյģ¬·ñÔò²»¿ÉÒÔÊìÁ·ÔËÓÃjava£¬Ò²²»»áʹÓþͺÜÄÑ°ìÁË¡£
1¡¢java.lang°üϵÄ80£¥ÒÔÉϵÄÀàµÄ¹¦ÄܵÄÁé»îÔËÓá£
2¡¢java.util°üϵÄ80£¥ÒÔÉϵÄÀàµÄÁé»îÔËÓã¬ÌرðÊǼ¯ºÏÀàÌåϵ¡¢Õý¹æ±í´ïʽ¡¢Ê±¼ä¡ ......