Java³ÌÐò£¬Ò»¸öʵÏÖEnumerationµÄ×éºÏÀà
import java.util.Enumeration;
public class CipherTest implements Enumeration {
private int N;
private int c[], k;
private Object[] objs;
public CipherTest(Object[] items) {
N = items.length;
c = new int[N + 1];
for (int i = 0; i <= N; i++)
c[i] = i;
objs = items;
k = 1;
}
public boolean hasMoreElements() {
return (k < N);
}
public Object nextElement() {
int i = 0;
if ((k & 1) != 0)
i = c[k];
Object tmp = objs[k];
objs[k] = objs[i];
objs[i] = tmp;
k = 1;
while (c[k] == 0)
c[k] = k++;
c[k]--;
return objs;
}
public static void main(String[] args) {
// String[] strs = { "1", "2", "3", "4" };
Integer[] nums = new Integer[6];
for (int i = 0; i < nums.length; i++)
nums[i] = i + 1;
System.out.println("N=" + nums.length);
Enumeration e = new CipherTest(nums);
int count = 0;
while (e.hasMoreElements()) {
Object[] a = (Object[]) e.nextElement();
if (((Integer) a[0]).intValue() != 4)
continue;
boolean isContinue = false;
for (int i = 0; i < a.length - 1; i++) {
if ((((Integer) a[i]).intValue() == 2 && ((Integer) a[i + 1])
.intValue() == 3)
|| (((Integer) a[i]).intValue() == 3 && ((Integer) a[i + 1])
.intValue() == 2)) {
isContinue = true;
break;
}
}
if (isContinue)
continue;
System.out.print("{" + a[0]);
for (int i = 1; i < a.length; i++)
System.out.print(", " + a[i]);
System.out.println("}");
count++;
}
System.out.println("count=" + count);
}
}
Ïà¹ØÎĵµ£º
ÔÚjavaÖУ¬¼ÙÉèÄãÓÐÒ»¸öuser ¶ÔÏóµÄlist£¬´Ëuser¶ÔÏó·â×°ÁËÓû§µÄid, first name, last name and age. È»ºóÄãÏëµ÷ÓÃÒ»¸öweb service(eg. UserService.deleteUsersByIds(List<Integer> userIds) ȥɾ³ýÊý¾Ý¿âÖÐÖ¸¶¨µÄÕâЩuser¡£ ÌýÆðÀ´Ëƺõ²»Ì«À§ÄÑ£¬²»ÊÇô? ÄãËùÐèÒªÖ»Êǽ« List<User> ת»¯³ÉList&l ......
public class bubblesort {
public static void main(String[] args) {
int array[]=new int[]{1,5,9,4,6,2};
int m;
for(int i=0;i<array.length;i++){
System.out.print(arra ......
javaÉú³Éexcel±í¸ñ£¬ÒÔǰֻ֪µÀPOI£¬ÕâÊÇApacheµÄ¿ªÔ´ÏîÄ¿£¬±¾À´ÊÇÒ»Ì׵쬰üÀ¨word£¬µ«ÊÇÒòΪwordµÄ¸´ÔÓÐÔ£¬ÒÔ¼°¿ª·¢ÈËÔ±µÄȱ·¦£¬ºÃÏñ»ù±¾Í£ÖÍÁË¡£Ö»ÓÐExcel×öµÄ»¹Ëã±È½ÏÍêÕû£¬ÓÃÆðÀ´±È½ÏÇáËÉ¡£
ºóÀ´ÒòΪ×öÏîÄ¿µÄ¹ØÏµ£¬ÖªµÀÁË»¹ÓиöJXL£¨java excel£©£¬Ò²ÊǸö¿ªÔ´ÏîÄ¿£¬ÓÃÆðÀ´µÄ¸Ð¾õ¸úPOIºÜÀàËÆ£¬ÒòΪ ......
Ò».ÔÚj2seÀïÎÒÃÇ¿ÉÒÔʹÓÃMath.random()·½·¨À´²úÉúÒ»¸öËæ»úÊý£¬Õâ¸ö²úÉúµÄËæ»úÊýÊÇ0-1Ö®¼äµÄÒ»¸ödouble£¬ÎÒÃÇ¿ÉÒÔ°ÑËû³ËÒÔÒ»¶¨µÄÊý£¬±ÈÈç˵³ËÒÔ100£¬Ëû¾ÍÊǸö100ÒÔÄÚµÄËæ»ú£¬Õâ¸öÔÚj2meÖÐûÓС£
¶þ.ÔÚjava.utilÕâ¸ö°üÀïÃæÌṩÁËÒ»¸öRandomµÄÀ࣬ÎÒÃÇ¿ÉÒÔн¨Ò»¸öRandomµÄ¶ÔÏóÀ´²úÉúËæ»úÊý£¬Ëû¿ÉÒÔ²úÉúËæ»úÕûÊý¡¢Ëæ»úfloat¡¢ ......
1¡¢½«String/StringBuffer±äÁ¿µÄÖµÖÃΪnull£¬ÔòÆäËùÕ¼ÄÚ´æ»áºÜ¿ì±»»ØÊÕ¡£
2¡¢ÔËÐйý³ÌÖнöÒÀÀµÓÚÊäÈë²ÎÊýµÄ·½·¨£¬ÈçÊýѧ·½·¨£»¾²Ì¬³ÉÔ±±äÁ¿³£Îª¶¨Òå³£Êý£¬ÓÃÏÞ¶¨´Êpublic static final£»¾²Ì¬³ÉÔ±±äÁ¿¿É½ÚÊ¡ÄÚ´æ¡£
3¡¢½Ó¿Ú£ºÈôÓÐÐèÍê³É³éÏóµÄ¶¯×÷»ò¾ßÓиÅÄîÐÔµÄÊôÐÔ£¬ÔòÔÚ½Ó¿ÚÖж¨Òå¸Ã¶¯×÷»ò¸ÅÄÔÚʵÏָýӿڵÄÀàÖоßÌå» ......