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).
On this page of the site you can watch the video online String In Java | String Advanced Concepts | What Is Heap Memory And String Constant Pool (SCP) with a duration of hours minute second in good quality, which was uploaded by the user Pawan S Nair 19 July 2020, share the link with friends and acquaintances, this video has already been watched 2,525 times on youtube and it was liked by 62 viewers. Enjoy your viewing!