共 36 篇文章 |
|
理解oo:继承、多态、重写、重载、接口、抽象类。即 一个父类的引用可以指向一个子类对象。实际的意义就是:public Animal returnAnimal(Animal a){} 在这个方法中,可以返回一个Animal对象,可以传入一个animal对象,也可以传入和返回任何一个Extend Animal的子类对象。即子类中可以增加一个和父类中完全一样的方法,但是方法签名不一样,当... 阅203 转0 评0 公众公开 16-02-24 15:10 |
这一步中,对于JSP源程序文件是不同的,对于JSP,这个过程是这样的:即WEB容器调用JSP编译器,JSP编译器先查看JSP文件中是否设置有文件编码格式,如果JSP文件中没有设置JSP文件的编码格式,则JSP编译器调用JDK先把JSP文件用JVM默认的字符编码格式(也即WEB容器所在的操作系统的默认的file.encoding)转化为临时的Servlet类,然后再把它编译成UNIC... 阅34 转0 评0 公众公开 15-09-28 10:57 |
为了解遍历性能的真实差距,包括在遍历key+value、遍历key、遍历value等不同场景下的差异,我试着进行了一些对比测试。分别使用keySet、entrySet和values的多种写法测试三种场景:遍历key+value、遍历key、遍历value的场景。entrySet遍历key+value(写法1):3. 结论3.1 如果你使用HashMap同时遍历key和value时,keySet与entrySet方法的性能差... 阅16 转0 评0 公众公开 15-04-13 09:45 |
阅1886 转5 评0 公众公开 15-02-13 14:36 |
public static boolean useList(String[] arr, String targetValue) {public static boolean useSet(String[] arr, String targetValue) {Set<String> set = new HashSet<String>(Arrays.asList(arr));public static boolean useLoop(String[] arr, String targetValue) {for (String s : arr) {public static boolean useArraysBi... 阅238 转0 评0 公众公开 15-02-09 09:54 |
开发中请勿这样写,如果发生异常流关闭不了 ObjectMapper mapper = CommonUtil.getMapperInstance(false); StringWriter writer = new StringWriter(); JsonGenerator gen = new JsonFactory().createJsonGenerator(writer); mapper.writeValue(gen, obj); gen.close(); String json = ... 阅16 转0 评0 公众公开 15-01-22 16:35 |
java文件过滤器(File类listFiles方法可选参数)有时候需要在程序中查找某一目录下的某一类文件,例如需要在E:\data\file_selector_test 目录下面查找所有已.java为后缀名的文件。} public static void main(String[] args) { File directory = new File("E:\\data\\file_selector_test"); 阅1271 转5 评0 公众公开 14-07-02 16:43 |
通过查看源代码发现,调用这个方法keySetMap.keySet()会生成KeyIterator迭代器,其next方法只返回其key值.而调用entrySetMap.entrySet()方法会生成EntryIterator 迭代器,其next方法返回一个Entry对象的一个实例,其中包含key和value.二者在此时的性能应该是相同的,但方式一再取得key所对应的value时,此时还要访问Map的这个方法,这时,方式一多遍历... 阅63 转0 评0 公众公开 14-05-06 16:01 |
使用common使用apache的commons-pool完成了一个简单的可伸缩的线程池,实现的功能为: 1、可以为线程池设定最大线程数,当有请求的时候,从池从取出一个线程来进行处理,当处理完成后,再将线程重新放入到池中。 阅41 转0 评0 公众公开 14-05-06 15:25 |
} public GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int minIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle, long softMi... 阅56 转0 评0 公众公开 14-05-06 15:01 |