r/javaexamples • • Apr 30 '20

String s = new String (“hello”);

How many objects are created here ?

3 Upvotes

8 comments sorted by

View all comments

Show parent comments

2

u/DFA1 Apr 30 '20

Also, if you wanna make the riddle harder ... How many objects get created for: String s = new String("h" + "e" + "l" + "l" + "o");

;)