随笔分类 -  java

java8-2-Lambda表达式
摘要:java8的lambda表达式:使得代码更加紧凑;修改方法的能力;更好的支持多核处理(并行处理函数和filter\map\reduce) 例子1: java7中,list集合排序: java8中,list集合排序: 例子2: Thread的处理: 例子3: 迭代处理: 例子4: labmda表达式和 阅读全文
posted @ 2018-01-15 09:04 zhaofeng555 阅读(284) 评论(0) 推荐(0)
java8-1-interface接口
摘要:Java 8 允许我们使用default关键字,为接口声明添加非抽象的方法实现。这个特性又被称为扩展方法 sample: interface Formula { double calculate(int a); default double sqrt(int a) { return Math.sqr 阅读全文
posted @ 2018-01-15 08:55 zhaofeng555 阅读(176) 评论(0) 推荐(0)
JUC集合-BlockingQueue
摘要:BlockingQueue 阻塞队列,支持两个附加操作。 1,在队列为空时,获取元素的线程会等待对列变为非空。 2,在队列为满时,存储元素的线程会等待对列可用。 使用场景: 生产者往对列里添加元素 消费者从对列里拿元素 操作 抛出异常:满队列时,执行入队会抛出异常;空队列时执行出队会抛出异常 。 返 阅读全文
posted @ 2018-01-12 20:10 zhaofeng555 阅读(669) 评论(0) 推荐(0)
java 编辑报错 非法字符: \ufeff 解决方案
摘要:用Notepad ++ 调成utf-8 格式 bom 或无bom根据情况 新建类 把代码一句句粘进去 ok 阅读全文
posted @ 2016-01-13 13:49 zhaofeng555 阅读(5422) 评论(0) 推荐(0)
java下载csv文件,中文标题
摘要:@RequestMapping(value = "/export.do")public void exportpushuserByareacode(HttpServletRequest req, HttpServletResponse rsp) throws Exception { List list = .....; String name="导出的文件.csv"; name = new String(name.getBytes("GBK"), "ISO8859-1"); rsp.setContentType(& 阅读全文
posted @ 2014-03-26 10:40 zhaofeng555 阅读(1868) 评论(0) 推荐(0)
java排序算法-归并排序
摘要:public class MergeSort { private static void mergeSortTest() { int[] in = { 2, 5, 3, 8, 6, 7, 1, 4, 0, 9 }; Utils.printArray("归并排序前:",in); int a[] = mergeSort(in); Utils.printArray("归并排序后:",a); } private static int[] mergeSort(int[] arr) { if (arr.length == 1) { return arr; } els 阅读全文
posted @ 2014-03-11 21:00 zhaofeng555 阅读(138) 评论(0) 推荐(0)
java排序算法-插入排序
摘要:public class InsertSortUtils { public static void main(String[] args) { insertSortTest(); shellSortTest(); } private static void insertSortTest() { int[] values = { 5, 2, 4, 1, 3 }; System.out.print("直接插入排序前: "); Utils.printArray(values); insertSort(values); System.out.print("直接插入排序后: 阅读全文
posted @ 2014-03-11 20:59 zhaofeng555 阅读(144) 评论(0) 推荐(0)
java排序算法-交换排序
摘要:public class ExchangeSortUtils { // 冒泡 public static void bubbleSort(int[] array) { int length = array.length; int temp; boolean isSort; for (int i = 1; i array[j + 1]) { // 交换 temp = array[j]; array[j] = array[j + 1]; array[j + 1] = temp; isSort = true; } } if (!isSo... 阅读全文
posted @ 2014-03-11 20:58 zhaofeng555 阅读(300) 评论(0) 推荐(0)
java排序算法-选择排序
摘要:public class SelectionSort { private static void selectSortTest() { int[] sortArray = { 5, 2, 4, 1, 3 }; System.out.print("选择排序前: "); Utils.printArray(sortArray); selectSort(sortArray); System.out.print("选择排序后: "); Utils.printArray(sortArray); } public static void selectSort(int[ 阅读全文
posted @ 2014-03-11 20:56 zhaofeng555 阅读(142) 评论(0) 推荐(0)
java里遍历map的常见方式
摘要:public static void main(String[] args) { Map map = new HashMap(); map.put("1", "value1"); map.put("2", "value2"); map.put("3", "value3"); //第一种:普遍使用,二次取值 System.out.println("通过Map.keySet遍历key和value:"); for (String key : map.keySet 阅读全文
posted @ 2013-11-15 12:49 zhaofeng555 阅读(216) 评论(0) 推荐(1)
PermGen space 与 Java heap space
摘要:1.java.lang.OutOfMemoryError: PermGen spacePermGen space的全称是Permanent Generation space,是指内存的永久保存区域OutOfMemoryError: PermGen space从表面上看就是内存益出,解决方法也一定是加大内存。说说为什么会内存益出:这一部分用于存放Class和Meta的信息,Class在被 Load的时候被放入PermGen space区域,它和和存放Instance的Heap区域不同,GC(Garbage Collection)不会在主程序运行期对PermGen space进行清理,所以如果你的 阅读全文
posted @ 2013-11-01 12:01 zhaofeng555 阅读(612) 评论(0) 推荐(0)
java vm内存设置
摘要:1、普通java应用程序,使用java命令运行, java -Xms1024m -Xmx1024m -XX:MaxNewSize=256m -XX:MaxPermSize=256m -jar 2、tomcat 在catalina.bat的set JAVA_OPTS修改为set JAVA_OPTS=-Xms1024m -Xmx1024m -XX:MaxNewSize=256m -XX:MaxPermSize=256m –server 3、eclipse中运行应用程序 程序右键选属性->run/debug settings->选中应用程序->编辑->Arguments-&g 阅读全文
posted @ 2013-11-01 12:00 zhaofeng555 阅读(577) 评论(0) 推荐(0)