Skip to content

Tag: java

Default properties of Java Annotation

What are the exact default values of two meta annotations (Target and Retention) in a user defined annotation? Answer According to the source code, none of them has a default value, which means you must provide it, whenever you use the annotation. The meaning of the missing annotation is defined in the javado…

Multilanguage development

I would like to develop an application with two languages. Actually, the goal is to generate two differents application, one with a language (Java), the other on in another language (C#). I would like to use makefiles to help me generate one application or the other one, thanks to targets definition. I don&#8…

How to disable loggers of a class or of whole package?

I am using Apache Commons Logging ™. For now I wanted to use SimpleLog implementation, but when I changed the level, loggers from the libraries came out. I want it to turn them off. Is there a easy way to change log level for whole package (can Log4j do that)? I have tried to set org.apache.commons.logging.si…

HashMap with multiple values under the same key

Is it possible for us to implement a HashMap with one key and two values. Just as HashMap? Please do help me, also by telling (if there is no way) any other way to implement the storage of three values with one as the key? Answer You could: Use a map that has a list as the value. Map<KeyType, List<Value…

Remove multiple elements from ArrayList

I have a bunch of indexes and I want to remove elements at these indexes from an ArrayList. I can’t do a simple sequence of remove()s because the elements are shifted after each removal. How do I solve this? Answer Sort the indices in descending order and then remove them one by one. If you do that, the…