spiderjava

    public static void main(String[] args) {
        User ut= new User();
        setNull(ut);
        System.out.println(ut.getAge()); // 18
    }

    private static void setNull(User utTemp) {
        // 本想在这里将不符合规则的数据全都置为空, 然后不保存,结果就有问题了
        // 这里只是把引用指向了空, 而没将对象置为空,外面的引用仍没变
        utTemp.setAge(18);
        utTemp = null;
        System.out.println(utTemp); // null
    }

其实就是effective 说的 命令式方法(返回新的方法) 或函数式方法(操作传入的对象并返回)

 

2. 代码好久不更新了 强制pull

git fetch --all  
git reset --hard origin/master 
git pull

3. 

git提交报错  对象hash值不对

error: invalid object 100644 3604ee8e84ee739268b8d170e8cc64b0fe425a65 for 'zipkin-server-2.9.4-exec.jar'

重新计算就可以了

git hash-object -w 文件名

 

4.在进行两个Integer比较时, 数不能大于127或小于-128

否则会不从常量池中取数,而是自行创建

   private static class IntegerCache {
        static final int low = -128;
        static final int high;
        static final Integer cache[];

        static {
            // high value may be configured by property
            int h = 127;
            String integerCacheHighPropValue =
                sun.misc.VM.getSavedProperty("java.lang.Integer.IntegerCache.high");
            if (integerCacheHighPropValue != null) {
                try {
                    int i = parseInt(integerCacheHighPropValue);
                    i = Math.max(i, 127);
                    // Maximum array size is Integer.MAX_VALUE
                    h = Math.min(i, Integer.MAX_VALUE - (-low) -1);
                } catch( NumberFormatException nfe) {
                    // If the property cannot be parsed into an int, ignore it.
                }
            }
            high = h;

            cache = new Integer[(high - low) + 1];
            int j = low;
            for(int k = 0; k < cache.length; k++)
                cache[k] = new Integer(j++);

            // range [-128, 127] must be interned (JLS7 5.1.7)
            assert IntegerCache.high >= 127;
        }

        private IntegerCache() {}
    }






   public static Integer valueOf(int i) {
        if (i >= IntegerCache.low && i <= IntegerCache.high)
            return IntegerCache.cache[i + (-IntegerCache.low)];
        return new Integer(i);
    }

 5. 使用Arrays 回报 unsupportException   查看之后Arrays 生成的自己的内部arraylist  他和正常的ArrayList 共同继承了AbstractList 在使用remove时

没有将其实现, 1. 可以创建个真正的new ArrayList(li)  或使用工具 ColletionUtils.removeAll  即新生成一个新的list,不使用remove

  List<String> li = Arrays.asList(queryVO.getOrdersns());
  List<String> li2 = new ArrayList<>();
  li.removeAll(li2);

6.  生产上报nullPointException  却没有堆栈异常信息,很难确定是哪一行出的问题?

  当某个异常抛出次数特别多时,jvm 会优化, 之抛出异常二不打印异常信息, 所以要加上-XX:-OmitStackTraceInFastThrow 禁用该优化  

7. 写存储过程中,执行条件

create Produce(CID int)

delete from s1 where cid = CID

本意是cid 是s1的字段, 但由于传入的参数包含了CID 所以上面等价于 delete from s1 where true  所以应该替换成delete from s1 where s1.cid = CID

 

posted @ 2018-12-30 15:20  jojoworld  阅读(180)  评论(0编辑  收藏  举报