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

java»ù´¡ÈëÃÅѧϰ±Ê¼Ç(Ò»):bubblesortËã·¨¸öÈËѧϰ


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(array[i]+" ");
    }
   System.out.println();
 
  
   for(int k=0;k<array.length;k++)
   {
    for(int j=k+1;j<array.length;j++)
    {
      if(array[k]<array[j])
        {
      
              continue;
        }
              else{
               m=array[k];
               array[k]=array[j];
               array[j]=m;
              
               }
     
          }
    System.out.print(array[k]+" ");
   }
 }
}
¿ªÊ¼Ö®Ç°ÓÃ2¸öÊý×飻һ¸öÊý×é´æ·ÅÔ­Êý¾Ý£¡ÁíÒ»¸öÊý×éÓÃÀ´´æ·Å½á¹û£¡
ʵÏÖÆðÀ´×ÜÊǵ¯³öjava.lang.ArrayIndexOutOfBoundsException Êý×鳬³ö±ß½çʲôµÄÒì³££¡
Ò»À´»ù´¡ÊµÔÚ±¡Èõ£¡ ¶þÀ´Õ¼Óÿռä´ó£¡
ÔÚǶÌ×forÑ­»·Ï¶Ôj£»kµÄÔ¼ÊøÌõ¼þÐèҪעÒ⣻
֮ǰ¿´¹ýһЩ½Ì³Ì¶ÔÓÚ¶¨Òå±äÁ¿µÄλÖÃÓÐÒ»µãdzÏÔµÄÈÏʶ£»ÔÚforÑ­»·ÀïÃæ¶¨Òå±äÁ¿ µ±forÑ­»·½áÊøºó±ã¿ÉÒÔ±»»ØÊÕ£¡ÓÐÀûÓÚ¿Õ¼äµÄ½ÚÊ¡£»


Ïà¹ØÎĵµ£º

javaʵÏÖ¶ÔÏó³Ø

/*
 * @(#)ObjectPoolManager.java 1.00 2005-5-1
 *
 * Copyright 2005 BeanSoft Studio. All rights reserved.
 * PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package  ......

javaÖÐÊý×éÓëListÏ໥ת»»µÄ·½·¨

1.Listת»»³ÉΪÊý×é¡££¨ÕâÀïµÄListÊÇʵÌåÊÇArrayList)
¡¡¡¡µ÷ÓÃArrayListµÄtoArray·½·¨¡£
¡¡¡¡toArray
¡¡¡¡public <T> T[] toArray(T[] a)·µ»ØÒ»¸ö°´ÕÕÕýÈ·µÄ˳Ðò°üº¬´ËÁбíÖÐËùÓÐÔªËØµÄÊý×飻·µ»ØÊý×éµÄÔËÐÐʱÀàÐ;ÍÊÇÖ¸¶¨Êý×éµÄÔËÐÐʱÀàÐÍ¡£Èç¹ûÁбíÄÜ·ÅÈëÖ¸¶¨µÄÊý×飬Ôò·µ»Ø·ÅÈë´ËÁбíÔªËØµÄÊý×é¡£·ñÔò£¬½«¸ù¾ ......

javaÖÐÊý×éÓëListÏ໥ת»»µÄ·½·¨

1.Listת»»³ÉΪÊý×é¡££¨ÕâÀïµÄListÊÇʵÌåÊÇArrayList)
¡¡¡¡µ÷ÓÃArrayListµÄtoArray·½·¨¡£
¡¡¡¡toArray
¡¡¡¡public <T> T[] toArray(T[] a)·µ»ØÒ»¸ö°´ÕÕÕýÈ·µÄ˳Ðò°üº¬´ËÁбíÖÐËùÓÐÔªËØµÄÊý×飻·µ»ØÊý×éµÄÔËÐÐʱÀàÐ;ÍÊÇÖ¸¶¨Êý×éµÄÔËÐÐʱÀàÐÍ¡£Èç¹ûÁбíÄÜ·ÅÈëÖ¸¶¨µÄÊý×飬Ôò·µ»Ø·ÅÈë´ËÁбíÔªËØµÄÊý×é¡£·ñÔò£¬½«¸ù¾ ......

JAVAÅжÏ×Ö·û´®ÊÇ·ñΪÊý×Ö

StringתCharacterÊý×飬ÓÃCharacterµÄisDigitºÍisLetterº¯ÊýÈ¥Åжϡ£
public static boolean isNumeric(String str) {
for (int i = str.length(); i = 0;) {
if (!Character.isDigit(str.charAt(i))) {
return false;
}
}
return true;
}
public static boolean isNumeric(String str) {
Pattern patt ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ