易截截图软件、单文件、免安装、纯绿色、仅160KB

java:Set循环遍历的俩种方法使用

package collection;
import java.util.*;
public class NewSet {
 public static void main(String[] args) {
  Set<Student> students = new HashSet<Student>();
  for (int i = 0; i < 6; i++) {
   students.add(new Student("Happy"+i,"male"+i,20+i));
  }
  students.add(new Student("Happy0","male0",20));
  print(students);
  print2(students);
 }
 
 //循环遍历①for
 public static void print(Set<Student> newList){
  System.out.println("总数据:"+newList.size());
  /*Student student;
  for (int i = 0; i < newList.size(); i++) {
   student = (Student)newList
   System.out.println(student.toString());
  }*/
 }
 //循环遍历①Iterator
 public static void print2(Set<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串口编程2

    再次从网上查询,搜到了RXTXcomm.jar包比较好,是封装了comm.jar的方法。
    安装:
    1.copy rxtxSerial.dll to [JDK-directory]\jre\bin\rxtxSerial.dll
    2.copy RXTXcomm.jar to [JDK-directory]\jre\lib\ext\RXTXcomm.jar
  &nbs ......

java中文乱码解决总结


为什么说乱码是中国程序员无法避免的话题呢?这个首先要从编码机制上说起,大家都是中文和英文的编码格式不是一样,解码也是不一样的!如果中国的程序员不会遇到乱码,那么只有使用汉语编程。汉语编程是怎么回事我也不大清楚,应该是前年吧,我一朋友给我介绍汉语编程,怎么不错不错?当时因为学习忙没去关注这个,等我闲 ......

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:三种经典大排序汇总,冒泡,插入,选择

package arrays.myArray;
public class SortArr {
 public static void main(String[] args) {
  int[] arrInt = { 4, 7, 8, 5, 6, 3, 2, 3, 4 };
  maoPaoSort(arrInt);
  print("冒泡排序:", arrInt);
  arrInt = new int[]{ 4, 7, 8, 5, 6, 3, 2, 3, 4 };
 & ......

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" ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号