`
DavyJones2010
  • 浏览: 148300 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论
文章列表
How to iterate a stack in Java?     1> Pitfall: Using iterator to iterate Stack @Test public void iterateTest() { Stack<String> stack = new Stack<String>(); stack.push("I"); stack.push("Love"); stack.push("You"); for (String s ...
Effective Java 2nd Edition, Chapter 7, Item 42 Be careful when using var args. Do not abuse var args in our custmoized methods. 1) Painful Arrays.asList for Primitive Types package edu.xmu.guava.constant; import static org.junit.Assert.assertEquals; import java.util.Arrays; import java.uti ...

Java SE: Tips

1. How to compare equals for two List:     1> Writing boiler plate code     2> Use org.apache.commons.collections.ListUtils.isEqualList()          Benefit: Help us handle boiler plate code for null check. public static boolean isEqualList(final Collection list1, final Collection list2) { ...
1> MapMaker for creating ConcurrentMap instances. 2> CacheBuilder for creating LoadingCache and Cache instances. 3> CacheBuilderSpec for creating CacheBuilder instance from a formatted string 4> CacheLoader that is used by a LoadingCache instance to retrieve a single value for a give ...
1. Both hashCode() and equals() are defined in Object: public native int hashCode(); public boolean equals(Object obj) { return (this == obj); }     If our customized object doesn't override hashCode(), then hashCode will be generated according to the object's address.     If our customize ...
1. Java provides operators to perform bitwise and bit shift operations on int type.     The operators discussed in the section are less commonly used, the intent is to simply make you aware that these operators exist.   2.  Bitwise operators overview: Operator Name Example Result Description ...
1. Table 2. ImmutableCollections 3. Comparision Chain & Range 4. Ordering   1. Table: Map<R, Map<C, V>>     1> Create table package edu.xmu.guava.collection; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.jun ...
Builder Pattern:      The builder pattern is a design pattern that allows for the step-by-step creation of complex objects using the correct sequence of actions.      The construction is controlled by a director object that only needs to know the type of object it is to create. 1. Motivation   ...
1. Classes with useful static methods for working with lists, maps and sets 2. The Range class used to represent the boundaries around a continuous set of values 3. Immutable Collections 4. Bimaps 5. The Table collection type, which is a very powerful collection that is a replacement for using ...
1. Books to read:     1) Technology related         1> Getting Started with Google Guava -Bill Bejeck         2> Google Guice -Robbie Vanbrabant -Pending to Next Year         3> Effective Java -Joshua Bloch         4> Clean Code A Handbook of Agile Software Craftsmanship -Robert C ...
1) "Prefer composition to Inherentance." --From GOF   2) A word about checked exceptions:     The great value of exceptions is the unification of error reporting: a standard machanism by which to report errors, rather than the popourri of ignorable approaches that we had in C.     I ...
1) How to start jetty in Maven? http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin# http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#maven-http-connector <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSch ...
1. Function<F, T> & Functions 2. Predicate<T> & Predicates 3. Supplier<T> & Suppliers   1. Function & Functions     1> Function     With Java in its current state, we don't have closures as they exist in other languages.     For now, Java's answer to clos ...
1. Joiner     Comparasion between traditional approach and Guava approach: @Test public void buildStringTest() { List<String> data = Lists.newArrayList("A", "B", "C", null, "D", "E", "F"); String str = buildString(d ...
import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import org.apache.log4j.Logg ...
Global site tag (gtag.js) - Google Analytics