Java Strings Fundamentals at Tap Academy

📚 Day 20 at Tap Academy – Learning Strings in Java Today I learned about Strings in Java, a fundamental concept used in almost every program. 🔹 What is a String? A String is a collection of characters enclosed within double quotes (" "). In Java, Strings are objects, not primitive data types. 🔹 Types of Strings ✔️ Immutable Strings - Cannot be changed once created - Example: Name, Gender, DOB ✔️ Mutable Strings - Can be modified after creation - Example: Email ID, Password 🔹 Memory Concept - Strings created using literals are stored in the String Constant Pool (SCP) - Strings created using "new" keyword are stored in Heap Memory 🔹 Ways to Create Strings String s1 = "JAVA"; String s2 = new String("JAVA"); char[] ch = {'J','A','V','A'}; String s3 = new String(ch); 🔹 String Comparison ✔️ "==" → compares reference ✔️ ".equals()" → compares values String a = "Hello"; String b = "Hello"; System.out.println(a == b); // true System.out.println(a.equals(b)); // true 💡 Key Takeaway: Strings are powerful in Java, and understanding how they work helps in writing efficient and optimized code. #Java #Programming #Coding #JavaDeveloper #LearningJourney #TapAcademy #Day20

  • graphical user interface, text, application, chat or text message

To view or add a comment, sign in

Explore content categories