(New engineer Fugi and you. I think I'm writing Java code today)
"... and it's about time to make a string with the String class"
String string1 = "Hello";
String string2 = new String("Hello");
"I tried to change the writing style with playfulness." "This will make my seniors laugh!"
"Senior, I wrote the code, so please take a look." "It's funny" "Hmm, which one ...?" "Oh?" "Are you different from Puyi and you don't understand this difference?" "...? What's the difference?" "Differences in how to initialize the String class" "Difference ... Both have an instance of the String class. Is it different from making it? " "It can be said that it is, and it can be said that it is not." "One is a literal, the other is an instance."
String string1 = "Hello"; // Literal
String string2 = new String ("Hello"); // Instance
"Eh" "Really"
"What is the new character string?" "I'm in the heap area of memory" "Heap area ...? (; ^ Ω ^)" "Roughly speaking, it feels like a'material storage'." "It's a good idea to put the data necessary to execute the program." "Ah, I see." "I'll go back to the story." "For the new character string to be placed in the heap area" "After the string created by the assignment operator is placed on the heap" "The reference is registered in a string literal pool" "Mojiretsu Literal Pool?" "Saya" "The next time the same string that was registered here is created" "The program is a string of strings registered in a string literal pool. Return a reference and create a new instance. " "I understand somehow." "If you do the same string, you will use the same instance again, right?" "Well, if you say it, that's right." "In the first place, creating an instance is for a computer. It ’s a tough job. ” "Since, the String class that I often use does that hard work. I think I'll be able to do as much as I can. " "Hohe" "I learned" "Thank you (* ´ω `)"
https://it-trend.jp/development_tools/article/32-0041 Takashi Kawaba "Java Object-Oriented Thorough Explanation" (Shuwa System)
Recommended Posts