Please try to solve the challenge by yourself.

This will challenge your String pool concept. If the content of the String is the same then it will refer to the same instance memory unless you have a new instance, but in the case of StringBuilder and StringBuffer, it does not refer to the same instance memory because when you call toString() method of StringBuilder and StringBuffer class, it creates the copy of the content with a new instance.

The implementation of StringBuffer -> toString() method —

The implementation of StringBuilder -> toString() method —



#AccessModifiers #threads #randomClass

Will the above code snippet compile or not?

Try to solve the challenge by yourself.

Let's understand the concept first —

There is a final class which means it can not be inherited. There is a thread also which consumes a Runnable having a run() method…



Try to solve the challenge by yourself without any compiler’s help.

We already have one challenge on this concept. Whoever follows the publication might be able to solve this challenge. This challenge is based on CachedInteger. Here is the old challenge.

I will just mark down the answer, please go to the challenge for an explanation.

Challenge Your Java Skill


Please follow the publication.



1. 1
2. 0.9999999999999999
3. 1.0000000000000001
4. 0.9999999999999999D

Try to solve the challenge by yourself first.

The answer should be 1 but that’s not the case the answer is 0.9999999999999999 . Let’s see the bytecode —

public class JavaChallenge38 {
public JavaChallenge38() {

public static void main(String[] args) {

So, at compile time only all 0.1 will be added, but it’s weird; so many of you will get a question —

Is floating point math broken???

Please go through the following links, it will help you to understand the entire concept —

Thanks. Don’t forget to upvote.




Java Challenge: A Java question will be published every Saturday. Stay tuned!

Connect with wolfie/JavaChallenge