Day 12 of My Java Learning Journey at Tech Academy 🚀 Today’s session was a continuation of Strings in Java, and we explored some very important concepts that strengthened my understanding of how Strings work internally. Here are the key takeaways from today’s lecture 👇 🔹 String Concatenation Concatenation is used to combine two strings. There are two ways to perform concatenation: Using the + operator Using the concat() method 🔹 String Memory Allocation String literals are stored in the String Constant Pool. When we create a string using the new keyword, memory is allocated in the Heap area. Since String is an object, it follows object memory allocation concepts. 🔹 String Comparison Methods equals() → Compares content and returns true or false equalsIgnoreCase() → Compares content ignoring case differences These methods do NOT tell which string is greater or smaller. To compare lexicographically, we use: compareTo() → Returns 0 if equal Positive value if first string is greater Negative value if first string is smaller We tested this method using three different cases to understand it clearly. 🔹 Important Concept In Java, length is a method for Strings (length()), not a property. To extract a character from a String, we use the charAt() method — we cannot access it like an array. Every day, I’m gaining deeper clarity on Java fundamentals and improving my problem-solving skills step by step 💻✨ Excited to continue learning! #Java #JavaProgramming #JavaDeveloper #learningJourney #TechAcademy #Programming #CodingLife #SoftwareDevelopment #WomenInTech #LinkedInLearning #DeveloperJourney #ComputerScience #100DaysOfCode #TechCareer #JavaStrings
Java Strings: Concatenation, Memory Allocation, and Comparison Methods
More Relevant Posts
-
Day 14 of My Java Learning Journey at Tech Academy 🚀 Today’s session was a continuation of Strings in Java, and we explored some very important concepts that strengthened my understanding of how Strings work internally. Here are the key takeaways from today’s lecture 👇 🔹 String Concatenation Concatenation is used to combine two strings. There are two ways to perform concatenation: Using the + operator Using the concat() method 🔹 String Memory Allocation String literals are stored in the String Constant Pool. When we create a string using the new keyword, memory is allocated in the Heap area. Since String is an object, it follows object memory allocation concepts. 🔹 String Comparison Methods equals() → Compares content and returns true or false equalsIgnoreCase() → Compares content ignoring case differences These methods do NOT tell which string is greater or smaller. To compare lexicographically, we use: compareTo() → Returns 0 if equal Positive value if first string is greater Negative value if first string is smaller We tested this method using three different cases to understand it clearly. 🔹 Important Concept In Java, length is a method for Strings (length()), not a property. To extract a character from a String, we use the charAt() method — we cannot access it like an array. Every day, I’m gaining deeper clarity on Java fundamentals and improving my problem-solving skills step by step 💻✨ Excited to continue learning! #Java #JavaProgramming #JavaDeveloper #LearningJourney #TechAcademy #Programming #CodingLife #SoftwareDevelopment #WomenInTech #LinkedInLearning #DeveloperJourney #ComputerScience #100DaysOfCode #TechCareer #JavaStrings
To view or add a comment, sign in
-
-
🚀 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 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
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
-
-
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 17 of My Java Learning Journey Today I focused on range-based number programs in Java, which helped strengthen my understanding of loops, conditional logic, and number-based problem solving. Before starting these programs, I studied a small input-validation approach using the Scanner class to ensure the program accepts only valid integer input from the user. Example validation logic: System.out.print("Enter initial value: "); if(!scan.hasNextInt()){ System.out.println("Invalid input: Input must be positive integer."); scan.close(); return; } int start = scan.nextInt(); System.out.print("Enter final value: "); if(!scan.hasNextInt()){ System.out.println("Invalid input: Input must be positive integer."); scan.close(); return; } int end = scan.nextInt(); if(start < 0 || end < start){ System.out.println("Invalid input: Start must be non-negative, and End must be greater than or equal to Start."); scan.close(); return; } 👉 This validation ensures: ✔ Only integers are accepted ✔ The starting value is non-negative ✔ The ending value is greater than or equal to the starting value ➡️ Programs Practiced: 🔹 Armstrong numbers in a given range 🔸 Buzz numbers in a given range 🔷 Even and Odd numbers in a given range 🔶 Leap Years in a given range ⭐ Perfect numbers in a given range ✨ Prime numbers in a given range 🟢 Strong numbers in a given range 🔵 Automorphic numbers in a given range 🟣 Fibonacci series up to a given range 🟡 Neon numbers in a given range 🔺 Palindrome numbers in a given range 🔻 Spy numbers in a given range 💡 These exercises improved my logic-building and problem-solving skills in Java and helped strengthen my programming fundamentals. Looking forward to continuing the learning journey and improving my coding skills every day. #Java #JavaProgramming #CodingJourney #CodeNewbie #Programming #SoftwareDevelopment #DeveloperJourney #LearningToCode
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 18 of Java Learning at TAP Academy 🚀 Imagine building a Calculator application. Would you create methods like addInt(), addFloat(), and addDouble()? 🤔 That sounds exhaustive and hard to memorize! Today, I learned that Java has a smarter way to handle this: Method Overloading. Instead of remembering 10 different method names, we can use one name (e.g., add()) and let the Java Compiler do the heavy lifting. Here are my key takeaways from today’s deep dive into Compile-time Polymorphism: 💡 The Core Concept Method Overloading is having multiple methods with the same name, within the same class, but with different parameters. (Note: If you miss saying "within the same class" in an interview, the definition is incomplete!) ⚙️ Under the Hood: It’s not the JVM! I learned that Overloading is resolved by the Compiler, not the JVM. This is why it is known as: Compile-time Polymorphism Static Binding (or Early Binding) False Polymorphism (because it looks like one method, but it's actually many). 🔍 How the Compiler Decides (The 3 Rules) When we call a method, the compiler filters the best match in this order: 1️⃣ Checks the Method Name. 2️⃣ Checks the Number of Parameters. 3️⃣ Checks the Type of Parameters. 🔥 The Interview Differentiator: Type Promotion & Ambiguity Most candidates stop at the definition. But to stand out, you need to explain: Type Promotion: If an exact match isn't found, the compiler automatically promotes smaller data types (like int to float) to find a compatible method. Ambiguity: If the compiler finds two equally valid paths via promotion, it throws an error because it gets "confused." 🌍 We use it every day! I realized I’ve been using overloading since my first "Hello World" program. System.out.println() (Accepts String, int, char, etc.) String.substring() StringBuffer.append() A big thank you to Tap Academy for explaining not just how to code, but why the code behaves the way it does. Ready to dive into Object Orientation next! 💻 #Java #TapAcademy #CodingJourney #SoftwareDevelopment #MethodOverloading #OOPs #LearningEveryday #Tech #Programming #FullStackDeveloper
To view or add a comment, sign in
-
-
🚀 Day 21 of My Java Learning Journey Today, I explored String operations in Java and learned how to compare and combine strings effectively. 🔹 String Comparison Methods - "equals()" → Checks exact match (case-sensitive) - "equalsIgnoreCase()" → Ignores case differences - "compareTo()" → Compares lexicographically - Returns "0" → Strings are equal - Positive → First string is greater - Negative → First string is smaller 🔹 Concatenation Techniques - Using "+" operator String s1 = "Hello"; String s2 = "World"; System.out.println(s1 + " " + s2); - Using "concat()" method System.out.println(s1.concat(" ").concat(s2)); 🔹 Key Insight Strings are objects in Java, and all operations are performed using methods from the String class. 💡 Learning these basics helps build a strong foundation for advanced Java concepts. #Java #LearningJourney #Programming #Coding #Students #TechSkills
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
-
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