编程语言:Java
Java中String的hash函数分析
JDK6的源码: * Returns a hash code for this string. The hash code for a * String
object is computed as * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] * using int
arithmetic,…
java为什么要重写hashCode和equals方法
在我们的业务系统中判断对象时有时候需要的不是一种严格意义上的相等,而是一种业务上的对象相等。在这种情况下,原生的equals方法就不能满足我们的需求了,所以这个时候我们需要重写equals方法,来满足我们的业务系统上的需求。
In Java, difference between default, public, protected, and private
In Java, are there clear rules on when to use each of access modifiers, namely the default (package private), public, protected and private, while making class and interface and dealing with inheri...
JAVA使用堆外内存导致swap飙高
近期遇到一个堆外内存导致swap飙高的问题,这类问题比较罕见,因此将整个排查过程记录下来了 现象描述 最近1周线上服务器时不时出现swap报警(swap超过内存10%时触发报警,内存是4G,因此swap超过400M会触发报警),每次都是童鞋们通过重启tomcat解决的; 但导致的根本原因是什么呢?必须找到根本原因才行,总是这么重启就有点low了 问题排查 于是找了1台占用了swap但还未触发...
Interfaces with static fields in java for sharing 'constants'
I'm looking at some open source Java projects to get into Java and notice a lot of them have some sort of 'constants' interface. For instance, processing.org has an interface called PConstants.jav...