*** CORRECTION: on 1:20 of the video, it incorrectly states that String foo = "foo" is equivalent to:
String foo = new String("foo")
... this is not really true. In fact, it's also misleading to say that Strings are stored in the heap - they are actually stored in a specific place in the heap: "The String Pool". The 'new' keyword will create an object in the heap that references the string in the pool (or create one if it doesn't already exist). Creating a string without using the 'new' keyword will NOT create an additional string object in the heap; it will simply point to the string in the string pool or add it to the pool if it doesn't already exist. This is why "foo" == "foo" will be true (both point to the same string in the pool) and new String("foo") == "foo" will be false (the left part of the expression references an object in the heap, which then references the string in the pool BUT '==' checks for reference, NOT for value). ***
NOTE: a stack is a linear data structure with a particular order in which the operations are performed: first-in, last-out. Also, elements in the stack are encapsulated in frames. To learn more about the role of frames in the stack : https://stackoverflow.com/questions/1...
En esta página del sitio puede ver el video en línea REFERENCE vs VALUE TYPES - JAVA de Duración hora minuto segunda en buena calidad , que subió el usuario The Sukhdev 31 enero 2021, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 100 veces y le gustó 3 a los espectadores. Disfruta viendo!