Sort array with sorted collection construction. public class WordList { public static void main(String[] args) { Set<String> s = new TreeSet<String>(); // This will sort and filter the duplicated items in the string array automatically. Collec…
float和double类型的主要设计目标是为了科学计算和工程计算.他们执行二进制浮点运算,这是为了在广域数值范围上提供较为精确的快速近似计算而精心设计的.然而,它们没有提供完全精确的结果,所以不应该被用于要求精确结果的场合.但是,商业计算往往要求结果精确,这时候BigDecimal就派上大用场啦. package com.jqf.www; import java.math.BigDecimal; public class test3 { public static void main(Stri…
Hi guys, I am happy to tell you that I am moving to the open source world. And Java is the 1st language I have chosen for this migration. It's a nice chance to read some great books like "Effective Java 2nd Edition" and share the note for what I…
Chapter 3 Methods Common to All Objects Item 8: Obey the general contract when overriding equals 以下几种情况不需要你override这个类的equals方法:这个类的每一个实例天生就是unique的,比如Thread:这个类的父类已经override了equals,并已经足够:这是个private或者package的class,你确定equals永远不会被调用,保险起见这时候你其实可以overrid…