RUVIDEO
Поделитесь видео 🙏

String, String Pool, intern method in Java. Bengali-Ep:14 #bengalitutorial #learnjava #bengali

📁 Обучение 👁️ 18 📅 05.12.2023

Hi,
Hope you are all doing great. Let's learn together.
Join Telegram: ? https://t.me/contactajoydebnath

Chapters ❤
0:00 Introduction
00:21 What is String and Its Property
02:47 String is Immutable
05:09 Operator Overloading
07:12 StringBuffer and String Builder
10:16 Interfaces implemented by String
11:17 Different Ways to Create String
17:16 New keyword to Create String
21:53 Different String Methods
33:08 String Pool
43:36 Intern Method

Document Link -
https://docs.google.com/document/d/1LYwsMTjhDPtkoj6YsM2P0UP1unaLkP-Ipj7UPKSldn4/edit?usp=sharing

Note:
Java was developed by Sun Microsystems (which is now a subsidiary of Oracle) in the year 1995. James Gosling is known as the father of Java. Before Java, its name was Oak. Since Oak was already a registered company, James Gosling and his team changed the name from Oak to Java.

Core Java Playlist:
https://www.youtube.com/playlist?list=PL0LQjbMWLlS3AVp2LglGSvfV6ieUSsNMp

Spring Playlist:
https://www.youtube.com/playlist?list=PL0LQjbMWLlS3tXLVZBuLmsMJ9dU6JNtGD

Like, Comment, Share, and Subscribe.
Thank you again.

STS Link:
https://spring.io/tools

JDK Link:
https://www.oracle.com/java/technologies/downloads/

String
1. Basically, a String is a sequence of characters but it’s not a primitive type.
2. The string is an immutable object which means that it cannot be changed once it is created.
3. The string is the only class where operator overloading is supported in Java. We can concat two strings using the + operator. For example "a"+"b"="ab".
4. Java provides two useful classes for String manipulation - StringBuffer and StringBuilder.(Mutable).

1. String Literal
String str = "Hello";
This is the most common way of creating strings.
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.

2. By new keyword
String str = new String("Hello");
In such case, JVM will create a new string object in heap memory not in the pool, and the literal "Hello" will be placed in the string constant pool (If not present). The variable 'str' will refer to the object in a heap (not in the pool).

Few Methods

equals() and equalsIgnoreCase()
String class provides equals() and equalsIgnoreCase() methods to compare two strings. These methods compare the value of a string to check if two strings are equal or not. It returns true if two strings are equal and false if not.

split()
split(String regex): This method splits the string using a given regex expression and returns an array of strings.
split(String regex, int limit): This method splits the string using a given regex expression and returns an array of strings but the element of the array is limited by the specified limit. If the specified limit is 2 then the method returns an array of size 2.

length()
Java String length() method returns the length of the string.

substring()
This method returns a part of the string based on specified indexes.

concat()
String concatenation is a very basic operation in Java. A string can be concatenated by using the “+” operator or by using concat() method.

format(),replace(),contains(CharSequence s)...etc.

String Pool in Java
A string Pool in Java is a pool of Strings stored in Java Heap Memory. We know that String is a special class in Java and we can create String objects using a new operator as well as providing values in double-quotes.

A string pool is also an example of a Flyweight design pattern. String pool helps in saving a lot of space for Java Runtime although it takes more time to create the String. When we use double quotes to create a String, it first looks for a String with the same value in the String pool, if found it just returns the reference else it creates a new String in the pool and then returns the reference. However using a new operator, we force the String class to create a new String object in heap space. We can use intern() method to put it into the pool or refer to another String object from the string pool having the same value.

How many Strings are getting Created in the String Pool?
String str = new String("Hello");
Either 1 or 2 strings will be created. If there is already a string literal “Hello” in the pool, then only one string “Hello” will be created in the heap. If there is no string literal “Hello” in the pool, then it will be first created in the pool and then in the heap space, so a total of 2 string objects will be created.

String intern() Method
When the intern method is invoked, if the pool already contains a string equal to this String object as determined by the equals(Object) method, then the string from the pool is returned. Otherwise, this String object is added to the pool and a reference to this String object is returned.

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «String, String Pool, intern method in Java. Bengali-Ep:14 #bengalitutorial #learnjava #bengali», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.