摘要: package com.broadengate.fangxing;import java.util.ArrayList;import java.util.Collection;import java.util.HashSet;/** * 应该都知道 hashset 不允许放入重复的数据,那么他是根据什么来判断是否是重复的数据呢? * 在hashset中用到了hash算法,因为hashset底层也是用的Hashmap来存取数据 * ,在hashmap底层则是用的数组来存取,而在hashmap放数据的时候会用到hashcode * ,这就是hashmap存入的数据没有顺序的原因,他就是根据hash 阅读全文
posted @ 2011-10-24 22:26 常伟华 阅读(726) 评论(0) 推荐(0) 编辑
摘要: public class FinoIteratorTest {private int count;public FinoIteratorTest() {}public FinoIteratorTest(int a) {this.count = a;}public Integer next() {return dir(count++);}private int dir(int i) {if (i < 2)return 1;return dir(i - 1) + dir(i - 2);}/** * @param args */public static void main(String[] 阅读全文
posted @ 2011-10-24 22:24 常伟华 阅读(429) 评论(0) 推荐(0) 编辑
摘要: String str = "s是首发式fssf还ihsifh";System.out.println(sprit(str, 5));}/** * 截取汉字的程序 按照字节数截取 一个汉字2个字节,如输入: s是首发式fssf还ihsifh 截取3个字节 则应该打印s是 * * @param str * @param a * @return */public static String sprit(String str, int a) {int index = 0;try {byte[] bytes = str.getBytes("GBK");boolea 阅读全文
posted @ 2011-10-24 22:22 常伟华 阅读(151) 评论(0) 推荐(0) 编辑