String str1=new String("Hello");
Consider there is no instance of any String Object in the String Constant Pool (SCP) and heap. "Hello" doesn't exist anywhere either in Heap or SCP till now. And I'm executing this line of Code. How many objects it will create?
In some Articles they say it's created both in heap and scp and in some articles they say it's in heap only
References: In Only Heap: https://www.javatpoint.com/string-pool-in-java
In both heap and Scp: https://www.edureka.co/blog/java-string/#:~:text=By%20new%20keyword%20%3A%20Java%20String,the%20object%20in%20the%20heap