📚 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
Java Strings Fundamentals at Tap Academy
More Relevant Posts
-
🚀 Day 23 of Learning Java @ Tap Academy 📘 Mutable Strings in Java Today, I learned about mutable strings—strings whose values can be changed after creation. 🔹 Classes used: ✔️ StringBuffer ✔️ StringBuilder These classes are used to create modifiable (mutable) strings in Java. 🔹 StringBuffer Basics: ✔️ Default capacity is 16 ✔️ Used to create mutable strings Example: StringBuffer sb = new StringBuffer(); sb.append("Hello"); System.out.println(sb); 🔹 Important Methods: ✔️ append(String s) → Adds text to the end ✔️ length() → Returns length of string ✔️ capacity() → Returns current capacity ✔️ ensureCapacity(n) → Increases capacity 📌 Capacity formula: New Capacity = (old capacity × 2) + 2 🔹 StringTokenizer: Used to split a string into tokens. Example: String s = "Java Python SQL AI"; StringTokenizer st = new StringTokenizer(s, " "); while(st.hasMoreTokens()) { System.out.println(st.nextToken()); } 💡 Key Takeaway: Mutable strings are efficient when frequent modifications are required. #TapAcademy #Java #LearningJava #Day23 #CodingJourney #JavaBasics #100DaysOfCode
To view or add a comment, sign in
-
-
Day 40 of Learning Java: Method Overloading Instead of creating different method names for similar tasks, we can use the same method name but change the parameters — and Java figures out which one to call. -So what exactly is Method Overloading? It’s when multiple methods in the same class have: ✔ Same name ✔ Different parameter list That’s it. Simple idea, but very powerful. -Ways to overload a method • Change the type of parameters • Change the number of parameters • Change the order of parameters Example- Think of a login system: Login using username + password Login using mobile + password Both are login actions, right? So instead of writing different method names, we just overload: login(String username, String password) login(long mobile, String password) Same method name → different ways to use it -Another relatable one Payment systems 👇 COD UPI Card Net Banking Instead of: paymentByUPI(), paymentByCard()… We can just do: payment() payment(String upi) payment(long card) payment(String user, String pass) - Important things I learned • Just changing return type won’t work (it gives error) • Overloading happens at compile time • Works with static, private, and even final methods • Yes, even main() can be overloaded (but JVM only runs the standard one) #Java #LearningInPublic #100DaysOfCode #Programming #OOP #CodingJourney
To view or add a comment, sign in
-
-
Day 41 of Learning Java: Method Overriding If method overloading was about flexibility,method overriding is about customization. What is Method Overriding? It’s when a subclass provides its own implementation of a method that is already defined in the parent class. Same method name. Same parameters. But different behavior. 🔹 Simple example- class Parent { void watchTV() { System.out.println("Watching News/Serial"); } } class Child extends Parent { @Override void watchTV() { System.out.println("Watching Music/Sports"); } } Same method → different output depending on the object. • Parent defines a general behavior • Child modifies it based on its own need • This helps in writing more flexible and reusable code 🔹 Key points to remember • Method signature must be the same • Happens during runtime (runtime polymorphism) • Inheritance is required 👉 You cannot override: static methods private methods final methods 🔹 One important concept Parent ref = new Child(); ref.watchTV(); Even though the reference is of Parent, the method of Child gets executed. 👉 This is called dynamic method dispatch 🔹 About @Override It’s not mandatory, but it helps: ✔ Avoid mistakes ✔ Makes code more readable ✔ Ensures you’re actually overriding #Java #OOP #MethodOverriding #LearningInPublic #Programming#sql #branding
To view or add a comment, sign in
-
-
🚀 Understanding the Difference Between Array and ArrayList in Java As part of my learning journey with TAP Academy, I explored one of the most fundamental yet important topics in Java — the difference between Array and ArrayList. Here’s a quick comparison that helped me understand when to use what 👇 🔹 1. Size 📌 Array → Fixed size 📌 ArrayList → Dynamic (Resizable) 🔹 2. Data Type 📌 Array → Stores homogeneous data 📌 ArrayList → Can store heterogeneous data (as Objects) 🔹 3. Storage 📌 Array → Stores primitive data types & objects 📌 ArrayList → Stores only objects 🔹 4. Length vs Size 📌 Array → Uses length keyword 📌 ArrayList → Uses size() method 🔹 5. Import Requirement 📌 Array → No import required 📌 ArrayList → Requires import java.util.*; 🔹 6. Utility Classes 📌 Array → Uses Arrays utility class 📌 ArrayList → Uses Collections utility class 🔹 7. Methods Availability 📌 Array → Limited methods 📌 ArrayList → Rich set of built-in methods 🔹 8. Multidimensional Support 📌 Array → Supports multidimensional arrays 📌 ArrayList → No direct support for multidimensional structure 💡 Key Takeaway: Arrays are simple and efficient for fixed-size data, while ArrayList provides flexibility and powerful methods for dynamic data handling. Choosing the right one depends on the problem requirement. Grateful to TAP Academy for helping me build strong fundamentals step by step 🙌 #Java #ArrayVsArrayList #CollectionsFramework #Programming #LearningJourney #TAPAcademy #KeepGrowing TAP Academy
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 39 of learning java Today I learned something very important in Java, Object Creation. Syntax: "className objectName = new constructor();" Here’s what I understood: • The left side ("className objectName") is just declaring a reference variable. • The right side ("new constructor()") is where the actual object is created. • Memory is allocated only when we use the "new" keyword. • The constructor gets executed automatically when the object is created. • Without "new", no memory is allocated and no constructor runs. In short: Declaration != Object creation You need "new" to actually create and use the object. This concept made things much clear about how Java handles memory and execution internally. Thanks to my mentor Ashim Prem Mahto for the clear explanations and for always clearing my doubts. #Java #LearningJourney #Programming #JavaBasics #CodingLife #DeveloperJourney #TechLearning #Beginners #CodeNewbie #jvm #SoftwareEngineer #StudentLife
To view or add a comment, sign in
-
-
Day 37 of Learning Java Today I learned something interesting Illegal Forward Reference in Java. At first, it sounded complicated, but once I understood it, it actually made a lot of sense! Here’s what I learned: 🔹 What is Illegal Forward Reference? • It happens when you try to use a variable before it is declared. • Java doesn’t allow referencing a variable that comes later in the code. 🔹 Why does it happen? • Java reads code from top to bottom. • If a variable is used before it exists, the compiler throws an error. 🔹 Example of the issue: • Using a variable before declaring & defining it to a compile-time error. 🔹 How to fix it? • Always declare variables before using them. • we have to call static variable using ClassName.VarName. Thanks to my mentor Ashim Prem Mahto for the clear explanations and for always clearing my doubts. #Java #LearningJava #CodingJourney #Programming #DeveloperLife #CodeNewbie #JavaDeveloper #TechLearning #StudentLife #jvm
To view or add a comment, sign in
-
-
Day 49 of Sharing What I’ve Learned🚀 ArrayList in Java In the Java Collections Framework, ArrayList is one of the first classes that helps manage data easily and efficiently. 🔹 What is ArrayList? ArrayList is a dynamic array in Java that can grow and shrink automatically as elements are added or removed. Unlike normal arrays, you don’t need to worry about size — it manages that internally. 🔹 Key Features ✔ Maintains insertion order ✔ Allows duplicate elements ✔ Provides fast random access (index-based) ✔ Automatically resizes when needed 🔹 Why Not Use Arrays? Traditional arrays have limitations: ❌ Fixed size ❌ Manual resizing ❌ Less flexibility ArrayList solves all of these problems with built-in methods. 🔹 Common Methods ✔ add() → Insert elements ✔ get() → Access elements ✔ set() → Update elements ✔ remove() → Delete elements ✔ size() → Get total elements 🔹 Example import java.util.ArrayList; public class Demo { public static void main(String[] args) { ArrayList<String> list = new ArrayList<>(); list.add("Java"); list.add("Python"); list.add("Java"); // duplicate allowed System.out.println(list); // [Java, Python, Java] list.remove("Python"); System.out.println(list.get(0)); // Java } } 🔹 When to Use ArrayList? ✔ When you need frequent data access ✔ When order matters ✔ When duplicates are allowed ✔ When size is not fixed 🔹 Key Insight ArrayList is powerful, but not always the best choice. If your use case involves frequent insertions/deletions in the middle, other structures like LinkedList may perform better. 🔹 Realization Learning ArrayList made me realize something important — Java is not just about writing logic, it’s also about choosing the right structure to support that logic. #Java #CoreJava #ArrayList #CollectionsFramework #DataStructures #Programming #DeveloperJourney #100DaysOfCode #CodingJourney #Day49 Grateful for guidance from, Sharath R TAP Academy
To view or add a comment, sign in
-
-
Day 57 of Sharing What I’ve Learned🚀 PriorityQueue in Java — Processing Based on Priority After learning how TreeSet keeps elements sorted, I explored something even more practical — PriorityQueue. 👉 It doesn’t just store elements… it processes them based on priority 🔹 What is PriorityQueue? PriorityQueue is a part of the Java Collections Framework that stores elements in a way where the highest (or lowest) priority element is always processed first. 👉 It is internally based on a Heap (Min-Heap by default) 🔹 How does PriorityQueue work? 👉 Elements are not stored in full sorted order 👉 Only the head element is guaranteed to be the smallest (default) 👉 Insertion and removal maintain heap structure ✔ peek() → gives highest priority element ✔ poll() → removes highest priority element 🔹 Why use PriorityQueue? ✔ Priority-Based Processing Elements are handled based on importance, not insertion order ✔ Efficient Operations Insertion & deletion are faster than full sorting ✔ Real-World Use Cases 👉 Task scheduling 👉 CPU job scheduling 👉 Dijkstra’s Algorithm 👉 Event-driven systems 🔹 Key Features ✔ Allows duplicate elements ✔ Does NOT allow null values ✔ Not thread-safe ✔ Default is Min-Heap (smallest first) 🔹 Important Methods ✔ add() / offer() ✔ poll() ✔ peek() ✔ remove() 🔹 When should we use PriorityQueue? 👉 Use it when: ✔ You need to process elements by priority ✔ You don’t need full sorting ✔ You want efficient retrieval of min/max 🔹 When NOT to use? ❌ When you need full sorted traversal → use TreeSet ❌ When insertion order matters → use LinkedList/Queue ❌ When random access is required 🔹 Key Insight 💡 PriorityQueue doesn’t sort everything… 👉 It only guarantees the most important element comes first 🔹 Day 57 Realization 🎯 Not all problems need full sorting… 👉 Sometimes, knowing the “next most important” element is enough #Java #PriorityQueue #DataStructures #CollectionsFramework #Programming #DeveloperJourney #100DaysOfCode #Day57 Grateful for guidance from, Sharath R TAP Academy
To view or add a comment, sign in
-
-
Day 4 of Learning Java : Today I started my journey into Java programming which is taught by Aditya Tandon Sir. Here are the key concepts I learned today: How Java Stores Negative And Floating Numbers? 1. Storing Negative Integers: Two’s Complement -- >Java doesn't just stick a "minus sign" in front of a number. Instead, it uses a system called Two’s Complement. In a standard 32-bit int, the most significant bit is the sign bit. • 0: Positive •1: Negative ∆ How to calculate Two's Complement: -->To store a negative number (like -5), Java follows these steps: 1.Start with the positive binary: 00000101 (for 5). 2.Invert the bits (One's Complement): 11111010. 3.Add 1: 11111011. 2. Storing Floating-Point Numbers: IEEE For float and double, Java follows the IEEE 754 standard. It stores numbers in a way similar to scientific notation but in binary. ∆ A 32-bit float is broken into three parts: 1.Sign Bit (1 bit): 0 for positive, 1 for negative. 2.Exponent (8 bits): Determines how large or small the number is (the "scale"). 3.Mantissa/Fraction (23 bits): Stores the actual digits of the number. This is just the beginning. Excited to continue this journey Special thanks to Rohit Negi bhaiya & Aditya Tandon Sir. #Day4 #Java #Coding #Learning #Consistency
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