Back to articles
πŸš€ Day 30 of My Automation Journey – Java Strings (Package, Memory, Limitations & Real-Time Usage) - part 2
How-ToSecurity

πŸš€ Day 30 of My Automation Journey – Java Strings (Package, Memory, Limitations & Real-Time Usage) - part 2

via Dev.tobala d kaveri

When learning Java, most people understand what a String is , but very few understand: πŸ‘‰ Which package it belongs to πŸ‘‰ Why it has limitations πŸ‘‰ How Java overcomes those limitations πŸ‘‰ Memory behaviour of Strings πŸ‘‰ Real-time usage in projects Let’s break everything down in a simple and practical way πŸ‘‡ πŸ“¦ 1. Which Package Does String Belong To? πŸ‘‰ The String class belongs to: java . lang . String Important Points: java.lang package is imported by default So you don’t need to write: import java.lang.String ; πŸ‘‰ That’s why we directly use: String name = "Bala" ; 🧱 2. What Type of Class is String? πŸ‘‰ String is a: Final class ❌ (cannot be inherited) Immutable class πŸ”’ (cannot be changed) public final class String Why final? πŸ‘‰ For security and consistency ⚠️ 3. Demerits of String in Java Even though String is powerful, it has some drawbacks: ❌ 1. Immutable (Cannot Modify) String s = "Hello" ; s = s + " World" ; πŸ‘‰ Creates new object every time ❌ 2. Memory Consumption Too many modifications β†’ too man

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles