follow me on:
Facebook: / pawans.nair.7
Instagram: / pawan_s_nair
Twitter: / pawannair
Linked in: / pawan-nair-669860168
In This video, we will discuss string in java
Definition :
Generally, String is a sequence of characters. But in Java, string is an object that represents a sequence of characters. The java.lang.String class is used to create a string object.
How to create a string object?
There are two ways to create a String object:
1.By string literal
2.By new keyword
Example:
String s ="hello";
Each time you create a string literal, the JVM checks the "string constant pool" first. If the string already exists in the pool, a reference to the pooled instance is returned. If the string doesn't exist in the pool, a new string instance is created and placed in the pool.
String s=new String("Welcome");
In such case, JVM will create a new string object in normal (non-pool) heap memory, and the literal "Welcome" will be placed in the string constant pool. The variable s will refer to the object in a heap (non-pool).
На этой странице сайта вы можете посмотреть видео онлайн String In Java | String Advanced Concepts | What Is Heap Memory And String Constant Pool (SCP) длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Pawan S Nair 19 Июль 2020, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 2,525 раз и оно понравилось 62 зрителям. Приятного просмотра!