Today’s Learning Update ✅ (Core Java — Strings) In today’s session, I learned one of the most important foundational topics in Java: Strings — how they are created, stored in memory, compared, and concatenated. 📌 Key Learnings: ✅ What is a String in Java? A String is a sequence/collection of characters enclosed in double quotes (" "). Also, Strings are objects in Java. ✅ Types of Strings Immutable String → cannot be changed (created using String class) Mutable String → can be changed (covered briefly; will be explored further) ✅ Ways to create an Immutable String Using new keyword Without new (String literal) Using char[] array and converting to String ✅ String Memory Concept (Very Important!) Java allocates String memory in two places inside Heap: String Constant Pool (SCP) → created without new, duplicates not allowed Heap Area → created with new, duplicates allowed ✅ Comparing Strings == → compares references (address) .equals() → compares values .equalsIgnoreCase() → compares values ignoring case .compareTo() → compares character by character (covered for later) ✅ String Concatenation Using + operator Using .concat() method ⚡ Important insight: + with two string literals → goes to SCP + with references → goes to Heap .concat() → always creates result in Heap 🧠 This session made me understand why String fundamentals are asked frequently in interviews, especially around == vs equals() and SCP vs Heap behavior. #Java #CoreJava #Strings #Programming #DSA #Learning #InterviewPreparation #SoftwareDevelopment #Coding TAP Academy
Java Strings: Creation, Memory, Comparison, and Concatenation
More Relevant Posts
-
📘 **Day 17 – Java Learning Journey** Today I explored one of the most important concepts in Java: **Strings**. Here are some key points I learned while practicing and analyzing my notes: 🔹 **What is a String?** A String is a sequence (collection) of characters enclosed within double quotes. Example: `"Java"` 🔹 **Strings are Objects in Java** Unlike primitive data types, Strings are objects created from the `String` class. 🔹 **Immutable Nature of Strings** Strings in Java are **immutable**, meaning once a String object is created, its value cannot be changed. 🔹 **Different Ways to Create Strings** 1️⃣ `String s = "Java";` → Stored in the **String Constant Pool** 2️⃣ `String s = new String("Java");` → Stored in **Heap Memory** 3️⃣ Using character arrays 🔹 **String Comparison Methods** ✔ `==` → Compares **references (memory location)** ✔ `.equals()` → Compares **values/content** ✔ `.compareTo()` → Compares **character by character** ✔ `.equalsIgnoreCase()` → Compares **ignoring case differences** 🔹 **String Concatenation** Strings can be combined using: • `+` operator • `concat()` method Understanding concepts like **String Constant Pool, Heap Memory, and Reference Comparison** helped me clearly see how Java manages memory. Every day I’m learning something new and strengthening my Java fundamentals step by step. 🚀 #Java #Programming #LearningJourney #JavaDeveloper #ComputerScience #Coding TAP Academy
To view or add a comment, sign in
-
-
🚀 Learning Update: Java — Method Overloading, Type Promotion, CLI Args & Encapsulation (OOP) In today’s live Java session, I revised some core concepts that are frequently tested in interviews and also form the foundation for Object-Oriented Programming. ✅ Key Learnings: 🔹 Method Overloading (Compiler-based / Compile-time Polymorphism) Multiple methods with the same name in the same class Java Compiler checks in order: Method Name Number of Parameters Type of Parameters If all 3 are the same → Duplicate method error If exact match isn’t found → Java tries Type Promotion (closest match) If more than one method becomes eligible after promotion → Ambiguity error 🔹 Can we overload main()? ✅ Yes, main method can be overloaded But JVM always starts execution from: public static void main(String[] args) Other overloaded main() methods can be called manually using an object/reference. 🔹 Command Line Arguments (CLI) Inputs passed in terminal get stored in String[] args Args are always Strings (even numbers) + with args performs concatenation, not addition (unless you convert manually) 🔹 OOP Introduction + Encapsulation (1st Pillar) Encapsulation = Protecting the most important data + giving controlled access Use private variables for security Provide controlled access using: ✅ Setter → set/update data (usually void) ✅ Getter → get/return data (has return type) Add validations inside setter (ex: prevent negative bank balance) 📌 Realization: These concepts are not just theory — they directly relate to writing secure, industry-ready code. #Java #OOP #Encapsulation #MethodOverloading #CommandLineArguments #LearningUpdate #FullStackDevelopment #PlacementPreparation #TapAcademy #SoftwareDevelopment TAP Academy
To view or add a comment, sign in
-
-
🚀 I completed Day 3 of my Java learning using the W3Schools platform.Today, I studied about java Operators, Strings, and Type Casting.” This helped me understand how Java handles data transformation and manipulation. First, I learned about Type Casting, which is used to convert one data type into another. I understood that Java is a strictly typed language, so data must be converted carefully when moving between different types. I also learned about automatic casting (widening) such as converting "int" to "double", and manual casting (narrowing) where a larger type like "double" is converted to a smaller type like "int", which may cause loss of decimal values. Next, I explored operators in Java, which act as the logic engine of a program. These include arithmetic operators ("+ - * / %"), assignment operators, comparison operators ("==, >, <, >=, <="), and logical operators ("&&, ||, !"). I also learned how the “+” operator can be used not only for arithmetic calculations but also for string concatenation. Another important concept I studied was Strings in Java. I learned that strings are objects with built-in methods that allow us to analyze and manipulate text. Some useful string methods include "length()", "charAt()", "indexOf()", and "toUpperCase()" which help in processing text data effectively. Finally, I saw how these concepts work together in a practical example where operators, type casting, and string concatenation are used to calculate and display a score percentage in a program. #Java #Programming #LearningJourney #SoftwareDevelopment #W3schools
To view or add a comment, sign in
-
🚀 Learning Update: Core Java — Method Overloading & Compile Time Polymorphism Today’s session helped me understand one of the most important OOP concepts in Java — Method Overloading, along with related concepts like compile-time polymorphism, type promotion, and ambiguity. 📌 Key Learnings: ✅ Method Overloading Learned that method overloading is the process of creating multiple methods with the same name within the same class, but with different parameters (number or type). ✅ Compile-Time Polymorphism (Static Binding / Early Binding) Understood that method overloading happens during the compilation phase and is handled by the Java compiler, not the JVM. ✅ Three Rules of Method Overloading Resolution: 1️⃣ Method Name 2️⃣ Number of Parameters 3️⃣ Type of Parameters These rules help the compiler decide which method should be executed. ✅ Type Promotion Learned how Java automatically converts data types to the closest compatible type when an exact method match is not available. ✅ Ambiguity in Method Overloading Explored scenarios where the compiler gets confused when multiple methods match equally, leading to ambiguity errors. ✅ Real-World Understanding A very interesting realization was that we already use method overloading in Java daily — for example, System.out.println() has multiple overloaded versions internally. 💡 Important Insight: Understanding concepts deeply with logic and real examples is much more powerful than just memorizing definitions — especially for technical interviews. Consistent practice and conceptual clarity are key to becoming a confident developer. #Java #CoreJava #Programming #MethodOverloading #OOP #LearningUpdate #CodingJourney #StudentDeveloper TAP Academy
To view or add a comment, sign in
-
-
🚀 Starting My Java Learning Journey – Day 6 🔹 Topic: Loops in Java Loops in Java are used to execute a block of code repeatedly until a certain condition is met. Java mainly provides three types of loops: 1️⃣ for Loop Used when the number of iterations is known. Example: public class Main { public static void main(String[] args) { for(int i = 1; i <= 5; i++) { System.out.println(i); } } } 2️⃣ while Loop Used when the number of iterations is not known beforehand. Example: public class Main { public static void main(String[] args) { int i = 1; while(i <= 5) { System.out.println(i); i++; } } } 3️⃣ do-while Loop The do-while loop executes the code at least once even if the condition is false. Example: public class Main { public static void main(String[] args) { int i = 1; do { System.out.println(i); i++; } while(i <= 5); } } 💡 Key Point: Loops help automate repetitive tasks and make programs more efficient. #Java #JavaLearning #Programming #BackendDevelopment #CodingJourney #JavaLoops
To view or add a comment, sign in
-
🚀 Learning Update: Understanding How a Java Program Actually Executes Today’s session helped me gain a deeper understanding of how Java programs execute internally beyond just writing code. 🔹 Java Compilation Process A Java program written in high-level language is first compiled using the Java Compiler (javac) which converts it into bytecode (.class files). If a file contains multiple classes, the compiler generates separate class files for each class. 🔹 Program Execution in JVM When we run a Java program: 1️⃣ The JVM loads the class containing the main method. 2️⃣ The bytecode is converted into machine-level instructions. 3️⃣ The program is executed inside the Java Runtime Environment (JRE). 🔹 Memory Structure in Java (JRE) During execution, the program uses different memory areas: • Code Segment – Stores compiled bytecode • Stack Segment – Stores method stack frames • Heap Segment – Stores objects created using new • Static Segment – Stores static variables 🔹 Role of Class Loader The Class Loader dynamically loads classes into memory when they are required during program execution. 🔹 Static vs Instance Concept • Static elements → belong to the class • Instance elements → belong to objects This concept explains why static methods can be accessed without creating an object, while instance methods require object creation. 💡 Key Insight: Understanding how JVM, class loading, memory segments, and object creation work internally helps in writing better and more optimized Java programs. Excited to keep exploring deeper concepts in Core Java and Object-Oriented Programming. #Java #JVM #Programming #OOP #SoftwareDevelopment #LearningJourney #JavaDeveloper TAP Academy
To view or add a comment, sign in
-
-
📚 Today’s Learning: String Concatenation & "concat()" Method in Java In today’s class, I explored an important concept in Java called String Concatenation and the "concat()" method. 🔹 String Concatenation String concatenation is the process of combining two or more strings into a single string. In Java, this is commonly done using the "+" operator. It helps developers create meaningful text outputs by joining variables and messages together. 🔹 "concat()" Method Java also provides the "concat()" method, which is a built-in method of the String class. This method is used to append one string to another string, producing a new combined string. 🔹 Important Concept – String Immutability One key concept behind these operations is that Strings in Java are immutable. This means the original string cannot be changed; instead, a new string object is created when concatenation happens. 💡 Key Takeaway: - "+" is an operator used for concatenation - "concat()" is a method of the String class used to join strings Learning these fundamental concepts strengthens my Java programming foundation and helps me understand how strings work internally. #Java #Programming #LearningJourney #StudentDeveloper #Coding TapAcademy
To view or add a comment, sign in
-
-
Day 13 – Exploring Strings in Java | My Learning Journey Today I continued my journey of learning Java and explored more concepts related to Strings. Strings are one of the most commonly used data types in programming because they help us work with text data effectively. 🔹 1. String Concatenation in Java String concatenation means combining two or more strings into a single string. In Java, this is commonly done using the + operator or the concat() method. Example: String firstName = "Hello"; String secondName = "World"; System.out.println(firstName + " " + secondName); Output: Hello World 🔹 2. Built-in Methods in String Java provides many built-in methods in the String class that help us perform operations easily. Some commonly used methods include: length() – Returns the length of a string charAt() – Returns the character at a specific index toUpperCase() – Converts string to uppercase toLowerCase() – Converts string to lowercase contains() – Checks if a string contains a specific value substring() – Extracts part of a string Example: String text = "Java Programming"; System.out.println(text.toUpperCase()); 🔹 3. StringTokenizer StringTokenizer is used to split a string into multiple tokens based on a delimiter like space, comma, or any other character. Example: import java.util.StringTokenizer; String str = "Welcome to Java"; StringTokenizer st = new StringTokenizer(str); while(st.hasMoreTokens()){ System.out.println(st.nextToken()); } Output: Welcome to Java Understanding string concatenation, built-in string methods, and String Tokenizer helps in handling and manipulating text data efficiently in Java applications. 💡 Every day I’m learning something new and improving my programming skills step by step. #Java #LearningJava #JavaProgramming #CodingJourney #Strings #DaysOfCode #DeveloperJourney
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
-
-
🚀 Learning Update: Core Java — String Methods & Comparison Concepts Today’s session helped me strengthen my understanding of Java Strings, especially how different comparison techniques and inbuilt methods work internally. 📌 Key Learnings: ✅ Understood the difference between • equals() → compares values (returns boolean) • equalsIgnoreCase() → compares ignoring case • compareTo() → compares character by character and returns an integer (positive, negative, or zero) ✅ Learned how compareTo() works internally using Unicode values and how it helps determine which string is greater or smaller — very useful for sorting logic. ✅ Explored important String inbuilt methods: • length() — returns number of characters • charAt() — fetches character using index • toLowerCase() & toUpperCase() — case conversion • indexOf() & lastIndexOf() — finding character positions • substring() — extracting part of a string • split() — converting string into array • startsWith() & endsWith() — checking patterns • toCharArray() — converting string into character array ✅ Gained clarity on String immutability — understanding that operations like concat() or case conversion create new objects instead of modifying the original string. 💡 Important Insight: In interviews, knowing only definitions is not enough — explaining concepts deeply with logic and examples makes a real difference. Consistent practice and strong fundamentals are the key to becoming a confident developer. #Java #CoreJava #Programming #CodingJourney #LearningUpdate #SoftwareDevelopment #JavaStrings TAP Academy
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