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

java£ºArrayListÑ­»·±éÀúµÄÁ©ÖÖ·½·¨Ê¹ÓÃ

package collection;
import java.util.*;
public class NewArrayList {
 public static void main(String[] args) {
  List<Student> students = new ArrayList<Student>();
  for (int i = 0; i < 6; i++) {
   students.add(new Student("Happy"+i,"male"+i,20+i));
  }
  print(students);
  print2(students);
 }
 
 //Ñ­»·±éÀú¢Ùfor
 public static void print(List<Student> newList){
  System.out.println("×ÜÊý¾Ý£º"+newList.size());
  Student student;
  for (int i = 0; i < newList.size(); i++) {
   student = (Student)newList.get(i);
   System.out.println(student.toString());
  }
 }
 //Ñ­»·±éÀú¢ÙIterator
 public static void print2(List<Student> newList){
  System.out.println("×ÜÊý¾Ý£º"+newList.size());
  Iterator<Student> iterator = newList.iterator();
  Student student;
  while (iterator.hasNext()){
   student = (Student)iterator.next();
   System.out.println(student.toString());
  }
 }
 
}


Ïà¹ØÎĵµ£º

Java´®¿Ú±à³Ì1

    ¹«Ë¾Óõ½´®¿Ú±à³Ì£¬¹Ê¿ªÊ¼Ñо¿£¬Ê×ÏÈËѵ½µÄÊÇjavacomm20-win32.zipÕâ¸öѹËõ°ü£¬°´ÕÕÍøÉϵݲװÅäÖúã¬ÈçÏ£º
    API
    ÔÚjavax.commÏÂÓÐ13¸öÀàºÍ½Ó¿Ú£¬·Ö±ðÊÇ
    4¸ö½Ó¿Ú
    CommDriver ¿É¸ºÔØÉ豸£¨the loadable device£©Çý¶¯³ ......

Java Ï̱߳à³ÌÖеÄͬ²½¡¢Öظ´¡¢¶¨Ê±

£¨Ò»£©Ïß³Ìͬ²½
ʵÏÖÉú²úÕßÏû·ÑÕßÎÊÌâÀ´ËµÃ÷Ïß³ÌÎÊÌâ,¾ÙÀýÈçÏÂËùʾ:
/**
* Éú²úÕßÏû·ÑÕßÎÊÌâ
*/
public class ProducerConsumer {

/**
* Ö÷·½·¨
*/
public static void main(String[] args) {
ProductBox pb = new ProductBox ......

java£º¶þ·Ö²éÕÒ·¨

package arrays.compara;
/**
 *
 * @author Happy ¶þ·Ö²éÕÒ·¨
 */
public class BinarySearch {
 public static void main(String[] args) {
  int[] arrInt = { 2, 34, 32, 24, 23, 34, 12, 3, 4, 2 };
  int index = bSearch(29, arrInt, 0, arrInt.length);
 & ......

java£ºObject¶ÔÏó½øÐÐÅÅÐò

package arrays.compara;
import java.util.Arrays;
public class Student {
 public static void main(String[] args) {
  Stu[] stus = new Stu[]{
    new Stu(156,34,"ad"),
    new Stu(153,24,"cc"),
    new Stu(126,37,"ab"), ......

java£ºÊÖдMyArrayLisyµÄ³£Ó÷½·¨£¬Ôöɾ¸Ä²é

package arrays.myArray;
public class MyArrayList {
 private Object[] arrObj = new Object[3];
 private int size = 0;
 
 // ³¤¶È
 public int size() {
  return size;
 }
 // insert
 public void add(Object obj) {
  add(size,obj);
&nb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ