易截截图软件、单文件、免安装、纯绿色、仅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 根据两点经纬度来算距离

package com.njty.util;
public class Test {
  private static final double EARTH_RADIUS = 6378137;
  private static double rad(double d)
     {
        return d * Math.PI / 180.0;
     }
     ......

中国公历算法&中国农历算法(JAVA)

中国公历算法不是太难,关键是星期值的确定。这里给出了简单算法: 
public static int dayOfWeek(int y, int m, int d) {
int w = 1; // 公历一年一月一日是星期一,所以起始值为星期日
y = (y-1)%400 + 1; //&n ......

java:手写二叉树BinaryTree添加和查询方法

package arrays.myArray;
public class BinaryTree {
 private Node root;
 // 添加数据
 public void add(int data) {
  // 递归调用
  if (null == root)
   root = new Node(data, null, null);
  else
   addTree(root, data);
......

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:四则混合运算,模拟微软的计算器

package arrays.myArray;
import java.util.Scanner;
public class SortObject {
 private static int intercePosition = 0; // 记录单个运算数据的长度
 private static int[] intercePositionIndex = null; // 记录“(”的下标
 private static int[] intercePositionEnd = null; // 记录 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号