Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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


Ïà¹ØÎĵµ£º

java¹¹ÔìÆ÷

Ô­×÷ÕߣºRobert Nielsen Ô­Õ¾£ºwww.javaworld.com
¡¡¡¡ÎÒÃÇ˵¹¹ÔìÆ÷ÊÇÒ»ÖÖ·½·¨£¬¾ÍÏó½²°Ä´óÀûÑǵÄѼ×ìÊÞÊÇÒ»ÖÖ²¸È鶯Îï¡££¨°´£ºÀÏÍâϲ»¶´ò±ÈÓ÷£¬ÎÒÒ²¾ÍÕÕ×Å·­Ò룩¡£ÒªÀí½âѼ×ìÊÞ£¬ÄÇôÏȱØÐëÀí½âËüºÍÆäËû²¸È鶯ÎïµÄÇø±ð¡£Í¬ÑùµØ£¬ÒªÀí½â¹¹ÔìÆ÷£¬ÄÇô¾ÍÒªÁ˽⹹ÔìÆ÷ºÍ·½·¨µÄÇø±ð¡£ËùÓÐѧϰjavaµÄÈË£¬ÓÈÆäÊǶÔÄÇЩҪÈÏÖ¤¿¼ÊÔ ......

Java×Ô¶¨ÒåÒì³£Àà

×Ô¶¨ÒåÒì³£ : ²½Öè: ­
Ò»:´´½¨Ò»¸öÀà¼Ì³ÐÓÚThrowable»òÆä×ÓÀà; ­
¶þ:Ìí¼Ó¹¹Ôì·½·¨; ­
Èý:ÔÚÒ»¸ö·½·¨ÖÐʹÓÃthrowÅ׳öÒì³£ ­
ËÄ:ÔÚÁíÒ»¸ö·½·¨Öв¶»ñ²¢´¦ÀíÒì³£ ­
ʾÀý:
Ò»¡¢ ¼Ì³ÐThrowable Àà
public class MySecondException extends Throwable {
public MySecondException() {
s ......

JavaºËÐÄAPIÐèÒªÕÆÎյij̶È


JavaµÄºËÐÄAPIÊǷdz£ÅÓ´óµÄ,Õâ¸ø¿ª·¢ÕßÀ´Ëµ´øÀ´Á˺ܴóµÄ·½±ã£¬¾­³£ÈËÓÐÆÀÂÛ,javaÈóÌÐòÔ±±äɵ¡£
µ«ÊÇһЩÄÚÈÝÎÒÈÏΪÊDZØÐëÕÆÎյ쬷ñÔò²»¿ÉÒÔÊìÁ·ÔËÓÃjava£¬Ò²²»»áʹÓþͺÜÄѰìÁË¡£
1¡¢java.lang°üϵÄ80£¥ÒÔÉϵÄÀàµÄ¹¦ÄܵÄÁé»îÔËÓá£
2¡¢java.util°üϵÄ80£¥ÒÔÉϵÄÀàµÄÁé»îÔËÓã¬ÌرðÊǼ¯ºÏÀàÌåϵ¡¢Õý¹æ±í´ïʽ¡¢Ê±¼ä¡ ......

javaÖеÄautoboxingºÍauto unboxing

  java 5¿ªÊ¼ÒýÈëÁËautoboxing ºÍauto-unboxing»úÖÆ£¬·½±ãÁË»ù±¾ÀàÐÍºÍÆä¶ÔÓ¦µÄwrapperÀàÐ͵Äת»»¡£±ÈÈçÎÒÃÇ¿ÉÒÔÖ±½Ó°ÑÒ»¸ö»ù±¾ÀàÐ͵ÄÖµ¸³¸øÆäwrapperÀàÐÍ£¬·´Ö®ÒàÈ»£»¿ÉÒÔ°ÑÒ»¸ö»ù±¾ÀàÐÍÖ±½Ó·ÅÈëÈÝÆ÷À·â×°µÄ¹ý³ÌÓɱàÒëÆ÷À´Íê³É£»µ÷Ó÷½·¨µÄʱºò¿ÉÒÔÖ±½ÓÆ¥Åä²ÎÊýautoboxingºÍauto-unboxingÖ®ºóµÄ°æ±¾¡£
¡¡Õâ¸ö¹ý³Ì ......

java³£ÓÃÀà blobFileBean

package com.whlongyi.sys.blob.bean;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
im ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ