🚀 Day 13 of My Java Learning Journey at Tapp Academy Today’s topic: Immutable & Mutable Strings in Java By default, Strings in Java are immutable. To work with mutable strings, Java provides two important classes: 🔹 StringBuffer 🔹 StringBuilder Here’s what I learned today 👇 🔸 StringBuffer • It is a class, so we must create an object. • Default capacity → 16 characters • Capacity growth formula → (currentCapacity × 2) + 2 • append() → Used to add content • length() → Returns the actual number of characters • trimToSize() → Adjusts capacity to match the actual length • delete(start, end) → Removes characters between given indexes • It is synchronized (thread-safe) Example: If the string contains 50 characters, the capacity might show 70. Using trimToSize() makes both length and capacity equal. 🔸 StringBuilder • Almost 90% similar to StringBuffer • Not synchronized • Faster compared to StringBuffer 📌 Key Difference: StringBuffer is thread-safe, while StringBuilder is not. Understanding these concepts helped me learn how Java manages memory, performance, and string manipulation efficiently. Learning step by step. Improving every day. 💻✨ Excited for Day 14! #Java #JavaProgramming #JavaDeveloper #StringBuffer #StringBuilder #ImmutableString #MutableString #CodingJourney #SoftwareDevelopment #WomenInTech #LearningEveryday #DeveloperJourney #100DaysOfCode #TechCareer #JavaLearning #ProgrammingLife
Java Immutable & Mutable Strings: StringBuffer & StringBuilder
More Relevant Posts
-
🚀 Day 15 of My Java Learning Journey at Tap Academy Today’s topic: Immutable & Mutable Strings in Java By default, Strings in Java are immutable. To work with mutable strings, Java provides two important classes: 🔹 StringBuffer 🔹 StringBuilder Here’s what I learned today 👇 🔸 StringBuffer • It is a class, so we must create an object. • Default capacity → 16 characters • Capacity growth formula → (currentCapacity × 2) + 2 • append() → Used to add content • length() → Returns the actual number of characters • trimToSize() → Adjusts capacity to match the actual length • delete(start, end) → Removes characters between given indexes • It is synchronized (thread-safe) Example: If the string contains 50 characters, the capacity might show 70. Using trimToSize() makes both length and capacity equal. 🔸 StringBuilder • Almost 90% similar to StringBuffer • Not synchronized • Faster compared to StringBuffer 📌 Key Difference: StringBuffer is thread-safe, while StringBuilder is not. Understanding these concepts helped me learn how Java manages memory, performance, and string manipulation efficiently. Learning step by step. Improving every day. 💻✨ Excited for Day 16. #Java #JavaProgrammer`` #JavaDeveloper #StringBuffer #StringBuilder #ImmutableString #MutableString #CodingJourney #SoftwareDevelopment #WomenInTech #LearningEveryday #DeveloperJourney #100DaysOfCode #TechCareer #JavaLearning #ProgrammingLife
To view or add a comment, sign in
-
-
Day 37 of My Java Learning Journey – Understanding toString() Method Today I learned about the toString() method in Java, which is defined in the Java Object class and is inherited by all classes. 🔹 What is toString()? It returns a string representation of an object. By default, it prints: ClassName@HashCode Example: Person@1ee0005 Person@6504e3b2 This output is not very meaningful when we want to display object details. 🔹 Solution: Override toString() By overriding the toString() method, we can display readable information about the object. Example output after overriding: [name = Mahesh, age = 24] [name = Dhanaraj, age = 30] ✅ Advantages of overriding toString() Provides meaningful object representation Makes debugging easier Improves readability of output Reduces the need for extra print statements 💡 Key Insight: Whenever we print an object using System.out.println(object), Java internally calls the toString() method. #Java #JavaLearning #OOP #ProgrammingJourney #Coding #Day37
To view or add a comment, sign in
-
-
📚 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
To view or add a comment, sign in
-
-
🚀 Learning Java – Understanding the Static Keyword Today I completed the "Static" concept in Java on TAP Academy. In Java, the keyword static is used for variables, methods, blocks, and nested classes. It means the member belongs to the class, not to individual objects. 1️⃣ Static Variable (Class Variable) A variable declared with static is shared by all objects of the class. Only one copy exists in memory. 2️⃣ Static Method A method declared as static can be called without creating an object. It can only directly access static variables and static methods. 3️⃣ Static Block Used for initializing static variables. It runs only once when the class is loaded. 4️⃣ Static Nested Class A class declared inside another class with static. It can access only static members of the outer class. #Java #Programming #Learning #TAPAcademy #SoftwareDevelopment #BTechStudent
To view or add a comment, sign in
-
-
🚀 Understanding Polymorphism in Java Polymorphism is one of the core concepts of Object-Oriented Programming (OOP). The word Polymorphism means “many forms.” In Java, it allows the same method or object to behave differently depending on the context or object calling it. 🔹 Types of Polymorphism 1️⃣ Compile-Time Polymorphism (Method Overloading) Occurs when multiple methods have the same name but different parameters. The decision of which method to call is made at compile time. 2️⃣ Run-Time Polymorphism (Method Overriding) Occurs when a child class provides a different implementation of a method defined in the parent class. The method call is resolved at runtime. 💡 Why Polymorphism is Important ✔ Improves code reusability ✔ Makes programs flexible and scalable ✔ Helps represent real-world scenarios in programming Understanding concepts like Polymorphism strengthens the foundation of writing clean, maintainable, and efficient code. 📚 Always learning and improving as a developer. #TAPAcademy #SharathR #LearningJourney #Java #OOP #Polymorphism #Programming #SoftwareDevelopment #LearningJourney
To view or add a comment, sign in
-
-
DAY 28: CORE JAVA 🚀 The Hidden "Guardrails" of Java Inheritance When learning Object-Oriented Programming, we often focus on what a child class gains from its parent. But the real mastery lies in understanding what stays behind. Based on my recent deep dive into Java mechanics, here are two critical rules that keep our code secure and logical: 1️⃣ Encapsulation > Inheritance There is a common misconception that inheritance "breaks" encapsulation. In reality, they support each other. * The Rule: Private members do not participate in inheritance. * The Why: If a child class could directly access the private variables of its parent, encapsulation would be shattered. Every pillar of OOP is designed to support the others; encapsulation ensures that even a "child" must respect the parent’s privacy. 2️⃣ Constructors: Unique to the Class Inheritance is about acquiring properties, but constructors are about creation. * The Rule: Constructors do not participate in inheritance. * The Why: A constructor’s name must always match the class name. If a Hacker class inherited a BankAccount constructor, it would create a naming conflict that breaks the fundamental rules of the language. 💡 The Takeaway Inheritance isn't a "copy-paste" of everything from the parent. It’s a selective process governed by strict rules that maintain the integrity of our objects. TAP Academy How do you explain the relationship between these two pillars to beginners? Let's discuss below! 👇 #Java #OOP #SoftwareDevelopment #CodingTips #BackendEngineering #TechLearning #Encapsulation
To view or add a comment, sign in
-
-
Day 16 of My Java Learning Journey at Tap Academy Today’s topic: Method Overloading in Java Today’s session helped me deeply understand one of the core concepts of Object-Oriented Programming — Compile-Time Polymorphism. Here’s what I learned 👇 🔹 What is Method Overloading? Method Overloading means defining multiple methods with the same name but different parameter lists within the same class. 🔹 Rules of Method Overloading: • Method name must be the same • Parameters must be different (number, type, or order) • Return type alone cannot differentiate overloaded methods 🔹 How Java Decides Which Method to Call? • Based on number of arguments • Based on type of arguments • Based on order of parameters • Happens at compile time (Static / Early Binding) 🔹 Type Promotion in Overloading If an exact match is not found, Java promotes smaller data types to larger ones according to the promotion hierarchy. 🔹 Ambiguity If multiple methods match equally and the compiler cannot decide, it results in a compile-time error called ambiguity. Understanding method overloading improved my clarity about how Java handles method calls and compile-time decision making. Step by step, building strong Java fundamentals 💻✨ Excited to continue this journey! #Java#JavaProgramming #MethodOverloading #OOP #JavaDeveloper #CodingJourney #LearningEveryday #SoftwareDevelopment #WomenInTech #DeveloperJourney #100DaysOfCode#TechCareer#ProgrammingLife #JavaLearning
To view or add a comment, sign in
-
-
Day 14 of My Java Learning Journey at Tap Academy Today’s topic: Method Overloading in Java Today’s session helped me deeply understand one of the core concepts of Object-Oriented Programming — Compile-Time Polymorphism. Here’s what I learned 👇 🔹 What is Method Overloading? Method Overloading means defining multiple methods with the same name but different parameter lists within the same class. 🔹 Rules of Method Overloading: • Method name must be the same • Parameters must be different (number, type, or order) • Return type alone cannot differentiate overloaded methods 🔹 How Java Decides Which Method to Call? • Based on number of arguments • Based on type of arguments • Based on order of parameters • Happens at compile time (Static / Early Binding) 🔹 Type Promotion in Overloading If an exact match is not found, Java promotes smaller data types to larger ones according to the promotion hierarchy. 🔹 Ambiguity If multiple methods match equally and the compiler cannot decide, it results in a compile-time error called ambiguity. Understanding method overloading improved my clarity about how Java handles method calls and compile-time decision making. Step by step, building strong Java fundamentals 💻✨ Excited to continue this journey! #Java #JavaProgramming #MethodOverloading #OOP #JavaDeveloper #CodingJourney #LearningEveryday #SoftwareDevelopment #WomenInTech #DeveloperJourney #100DaysOfCode #TechCareer #ProgrammingLife #JavaLearning
To view or add a comment, sign in
-
-
🚀 Learning Java OOP Understanding Object Class in Java As part of my learning journey in Java Object Oriented Programming, I explored one of the most fundamental concepts: the Object Class. 🔹 In Java, every class directly or indirectly inherits from the Object class 🔹 It acts as the root of the entire class hierarchy 🔹 Because of this, every object in Java automatically gets some default behaviors and methods 📌 Important Methods in the Object Class ✅ toString() → Converts object data into readable text ✅ equals() → Compares two objects for equality ✅ hashCode() → Generates a unique hash value for objects ✅ getClass() → Returns runtime class information ✅ clone() → Creates a duplicate copy of an object ✅ wait(), notify(), notifyAll() → Used in multithreading communication ⚠️ finalize() → Deprecated method (no longer recommended) 💡 Key Insight When we print an object reference using System.out.println(object), Java internally calls the toString() method. This is why overriding toString() helps display object data in a more meaningful and readable format. 📊 Did you know? The Object class contains 12 methods and 1 constructor, making it the ultimate parent of all Java classes. I’m excited to continue exploring deeper concepts in Java and OOP! #SharathR #TapAcademy #Java #OOP #ObjectClass #Programming #JavaDeveloper #SoftwareDevelopment #LearningJourney
To view or add a comment, sign in
-
-
🚀 Day 8 of Learning Java – Understanding Loops Deeply Today’s lecture was all about Loops and Jump statements in Java — and honestly, this is where programming starts to feel powerful. One simple question: 👉 Why do we use loops? Because sometimes we need to perform a specific instruction multiple times or in a repeated manner. Instead of writing the same line again and again, loops help us automate repetition efficiently. I explored all three major loops in Java and understood when and why to use each of them: 🔁 1. while Loop Used when we don’t know exactly how many times the loop should run. It checks the condition first, and if it’s true, then executes the code. 📌 Example: Reading user input until they enter a correct password. The loop continues while the condition is true. 🔄 2. for Loop Best when we know the exact number of iterations. It keeps initialization, condition, and update in one clean line. 📌 Example: Printing numbers from 1 to 10. When the number of repetitions is fixed, for loop is more structured and readable than while. ♻ 3. do-while Loop This one is interesting. It executes the task at least once, then checks the condition. 📌 Example: Displaying a menu at least one time before checking if the user wants to continue. 💡 Biggest Understanding Today: ✔ while → First checks condition, then executes ✔ do-while → Executes first, then checks condition That small difference changes behavior completely. Now I don’t just know how to write loops — Jump Statements : 🔹 break → Terminates (immediately exits) the loop. Control goes outside the loop. 🔹 continue → Skips the current iteration and moves to the next iteration of the loop. I understand when to use each one and why one is more suitable than the others in different situations. Step by step, the logic is getting stronger. From variables to memory to loops — the foundation is building steadily. Grateful for the guidance and clarity provided in every lecture. Special thanks to Aditya Tandon and Rohit Negi for explaining concepts so clearly and practically 🙌 Excited to continue this journey 🔥 #Java #LearningJourney #CoreJava #Programming #Consistency #Day8
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development