Removing whitespace from strings in Java

st.replaceAll(“\\s+”,””) removes all whitespaces and non-visible characters (e.g., tab, \n). st.replaceAll(“\\s+”,””) and st.replaceAll(“\\s”,””) produce the same result. The second regex is 20% faster than the first one, but as the number consecutive spaces increases, the first one performs better than the second one. Assign the value to a variable, if not used directly:

How to resolve Error listenerStart when deploying web-app in Tomcat 5.5?

You should not have any server-specific libraries in the /WEB-INF/lib. Leave them in the appserver’s own library. It would only lead to collisions in the classpath. Get rid of all appserver-specific libraries in /WEB-INF/lib (and also in JRE/lib and JRE/lib/ext if you have placed any of them there). A common cause that the appserver-specific libraries are included in the webapp’s library is that starters … Read more

Integer range when using 64bit jdk

The size of an int in Java is completely independent of the 32-bitness or 64-bitness of a JDK. It is always 4 bytes = 32 bits = −2,147,483,648 to 2,147,483,647. If you want a 64-bit integer, use a long, which is always 64 bits = 8 bytes.

Using Enum values as String literals

You can’t. I think you have FOUR options here. All four offer a solution but with a slightly different approach… Option One: use the built-in name() on an enum. This is perfectly fine if you don’t need any special naming format. Option Two: add overriding properties to your enums if you want more control Option Three: use static finals instead … Read more

Create a List of primitive int?

In Java the type of any variable is either a primitive type or a reference type. Generic type arguments must be reference types. Since primitives do not extend Object they cannot be used as generic type arguments for a parametrized type. Instead use the Integer class which is a wrapper for int: If your using Java 7 you can simplify … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)