Java Programming Tutorial 18 - String Comparison and Interning

preview_player
Показать описание


~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

🅑 Bitcoin - 3HnF1SWTzo1dCU7RwFLhgk7SYiVfV37Pbq
🅔 Eth - 0x350139af84b60d075a3a0379716040b63f6D3853
Рекомендации по теме
Комментарии
Автор

It's interesting. If you look at your video series on Java programming in your video section of your profile, you'll see that each lecture has less and less views. Thats like people who are dropping out of your lessons i guess. The class had 107K views on video 1 and now 3.3K on video 18 (Jul 6, 2019). So if you're a viewer reading this, Congratulations :D!

jllarivee
Автор

Fantastic video. Good explanation. It seems to make sense to me. When you're using literals to declare a string, in order to preserve memory, Java will check if the String already exists in memory and will return the reference to the memory position if the case is true AND will NOT check or add to the Java heap for a reference.

When you use the "new" operator, Java is forced to add an additional copy into the Java heap as a separate instance, as its been declared explicitly as a new object, and will check the memory to see if there is a matching string to reference. This prevents redundant data being stored into memory, while allowing separate instances to refer to the same data stored in memory. This means different instances of the String will not be equal, even if in memory, the data is the same, however, when checking String literals, you're only comparing the data in the memory itself, and not the instance attached to it.

Please let me know if my understanding is not correct.

bigollie
Автор

Kept failing a bunch of test cases because of this issue. I was doing a Data Structures assignment that I was absolutely confident that I was getting things correct in. I returned the correct Trie and search it efficiently. Only problem was that I was using == instead of .compareTo() or .equals(), so I must've been getting really lucky on my end that everything ended up working out, but on my professor's end when they ran their test cases, my code malfunctioned. Make sure to use these String methods and not the comparison operator people!

TheEpicPineapple
Автор

I've made it this far after trying many times to learn Java. I'm on the right track with this.

deezeed
Автор

omg mister i love u, reviewing for me first ever in the whole widest world ever program test im so excite but hope i dont fail wishing me luck great thankyou

ghostek
Автор

Damn. You are a master ! go on with your job, you are doing it the best! Thank you.

samggez
Автор

I wish every teacher could be like you!

averagehooligan
Автор

I think I deserve a chicken pot pie after this lesson hahahahaha

charissebulan
Автор

Day 1 🙌 Done 18 out of 100, 82 more to go let's go! 🔥

hihellookay
Автор

I made this far. Thanks to your tutorial 😊

jenalynreyes
Автор

So if I got it right, primitives ARE the value they contain, while strings with the same value get alloacated in the same one memory space, which makes he equals command compare the internal value for the 2 of them ?

nemkos
Автор

Nize, I have found my new mentor & master =D

homoculus
Автор

even less people made it to this one tutorial...

Martin-wzrm
Автор

caleb bro u have got to tell what song that is in the outro

shiwangkhera
Автор

C# for the win, never have this problem!

TheAuthorityOf
Автор

At 4:30 he compares both a and b. And if the == operator is true then the 2 values are the same right? So isn't that the expected output?

marco
Автор

P R A M P! You are incredible man. I should actually really try pramp to be honest

whyisaac
Автор

I'll go on Pramp if they promise to pair me with Claire.

amandaflood
Автор

Wait a minute. You did a = x and b = x in the later part of your video
Why would it return False if both a and b are equal to x.

Doesn't make sense if the comparison operator returns false.

lodashnotebook
Автор

a bit confusing to me but i will get it!

aricmistovich