Most answers for [java] and [jvm]

First to get the silver [jvm] badge, second to gold [performance] badge.

16h
comment How and why can a Semaphore give out more permits than it was initialized with?
@slott for that I would use an AtomicBoolean. You can set(true) to release and compareAndSet(true, false) to acquire. This is non blocking.
17h
comment Java multithreading: redundant to use java.util.concurrent classes in a synchronized method?
Please use StringBuilder instead of StringBuffer as it was replace ten years ago. It is near impossible to use StringBuffer correctly without external synchronization.
17h
comment Firewall in java
What have you tried? What code do you have? What does the request actually look like? What does a request which doesn't fail look like?
17h
comment How to reduce committed heap memory in JVM
I would only give the JVM the amount of memory you have available e.g. 3 GB perhaps and then you shouldn't need to restart it.
17h
revised Static and NonStatic
added 113 characters in body
17h
answered Static and NonStatic
17h
comment Calling methods within methods within methods... allowed in Java?
note: if your stack depth is in the thousands you will see problems such as a Stackoverflow in extreme case, but also a truncated stack trace (the default limit is 1000) In real programs you can get horribly nested stack traces (web service libraries tend to do this) and it can look overly complicated. So while in your case, it is simple enough that it probably doesn't matter, you do want to avoid a very deep stack traces. IMHO.
17h
comment Calling methods within methods within methods... allowed in Java?
You can do it either way. If you want to avoid the law of demeter in the first example, you can pass it a call back or lambda for it to call when it has a result. If you only have exactly one result is is likely to be over kill and the second example might be simpler. Note: if you can have one or more results, passing a lambda might be better.
17h
answered Java Classes & Objects, Could I have Coded This Better?
18h
comment Why there is no BooleanConsumer in Java 8?
@lbalazscs in java it is a feature of escape analysis. Instead of allocating an object on the heap it places it on the stack. The word should have been elision as in lock elision.
20h
comment How to return last added value from the HashMap
@JonSkeet LinkedHashMap is an extension of HashMap which also maintains a linked list to give it an order. The point of hash function is to give as close to a one to one mapping as possible even for a restricted range of values and a hash function is key to how a HashMap works. The random arrangement is needed to minimise collisions in the general use case which would otherwise turn a Map access from O(1) into O(N) in Java 7, or O (log N) with the use of a tree.
20h
comment how do we ensure a badge doesn't penalise a behaviour you might be trying to encourage?
@Cerbrus Yesterday I was contacted by another forum with the tag line "an ambitious community without power-trippin' mods and noob-stompin' haters" Clearly enough people hate hit and run downvoting.
20h
comment What would be the value of variable after executing the following statement
a is not a digit for decimal so you get a NumberFormatException. Note: if it was Hexidecimal you were parsing it would be 10
20h
comment How to return last added value from the HashMap
The whole point of a hash collection is to arrange the data randomly. What you could do is use LinkedHashMap which does keep the order of insertion, but it would perform pretty badly.
20h
comment Is this dictionary function thread-safe (ConcurrentHashMap+AtomicInteger)?
You could be right, but I wouldn't rely on it myself.
20h
comment How to code an intelligent coalesce in Java?
@GarouDan in theory, there is backports of the library but I haven't used any. Without the syntactic sugar I imagine using a library to be more painful than writing it yourself.
21h
revised How to code an intelligent coalesce in Java?
added 2 characters in body
21h
answered How to code an intelligent coalesce in Java?
21h
comment Is this dictionary function thread-safe (ConcurrentHashMap+AtomicInteger)?
If you use AtomicLong instead it will last 4 billion times longer. The missing ids should be rare and would have to be that the same word is added in two threads at the same moment.
21h
comment Dynamic if-then Code
Ok, what have you tried and what are you having trouble with? It sounds like you need to build a decision tree as a data structure and apply it to classify some inputs.
1 2 3 4 5