Did you know that List.of() and Set.of() create immutable collections in Java? What does that mean? You cannot add, remove, or modify elements after creation. Key Points: ❌ No modification allowed ❌ No null values allowed ✅ Safer (no accidental changes) ✅ Cleaner than Arrays.asList() When should you use it? - Constants - Read-only data - Defensive programming (protect your APIs) Common mistake: Treating it like a normal list → runtime exception #java #interview #immutable #certification
Eid Badr’s Post
More Relevant Posts
-
💡 Strings in Java — Small Concept, Big Impact At first, I thought Strings were simple… But in real projects, I learned: ➡️ Strings are immutable ➡️ Memory is optimized using String Pool ➡️ Wrong usage can impact performance Example mistake I made: String result = ""; for (int i = 0; i < 1000; i++) { result += i; // ❌ creates multiple objects } ✅ Better approach: StringBuilder sb = new StringBuilder(); for (int i = 0; i < 1000; i++) { sb.append(i); } ✨ What I learned: ✔ Use StringBuilder for heavy operations ✔ Understand equals() vs == ✔ Be mindful of memory Sometimes the simplest concepts teach the biggest lessons. #Java #Strings #CleanCode #SoftwareEngineering #BackendDevelopment #LearningJourney
To view or add a comment, sign in
-
-
Day 36/100 – Working with ArrayList in Java 📚 Today I practiced using ArrayList in Java, a dynamic array that allows flexible storage and manipulation of data. Unlike normal arrays, ArrayList can grow and shrink dynamically, making it very useful in real-world applications. Key learnings: • Adding elements using add() • Storing multiple values dynamically • Finding size using size() • Easier and more flexible than traditional arrays Understanding collections like ArrayList is important for handling data efficiently in Java. Building strong fundamentals step by step. 🚀 #100DaysOfCode #Java #ArrayList #DataStructures #CodingJourney #LearningInPublic
To view or add a comment, sign in
-
-
Java’s real breakthrough wasn’t syntax — it was portability. The Java Virtual Machine allowed organizations to rethink software distribution and deployment across diverse hardware and OS environments. A quick read for tech leaders and engineers: https://wix.to/GEDnmYF #Java #SoftwareArchitecture #TechLeadership #JVM
To view or add a comment, sign in
-
🚀 Beats 100% of all Java solutions on LeetCode! Just solved LeetCode #290 — Word Pattern in Java with 0ms runtime, outperforming every submission. Here's how I approached it 👇 🧩 Problem: Given a pattern (like "abba") and a string of words, check if the words follow the exact same pattern — a full bijection. e.g. pattern = "abba", s = "dog cat cat dog" → true ✅ 💡 My approach: Used a single HashMap<Character, String> to map each pattern character to its corresponding word. The key insight: also check containsValue() to prevent two different characters from mapping to the same word — ensuring true one-to-one bijection. 📊 Results: Runtime: 0 ms — Beats 100.00% 🌿 Memory: 42.65 MB — Beats 80.14% 🔑 Key takeaway: Always verify bijection in both directions — a one-way map is not enough for pattern matching problems. One extra containsValue() check is all it takes! All 44 test cases passed ✅ — Clean, simple, and blazing fast. #LeetCode #Java #DSA #CodingChallenge #ProblemSolving #100Percent #Programming #SoftwareEngineering #CompetitiveProgramming #HashMap
To view or add a comment, sign in
-
-
🚀 Day 21 of #128DaysOfCode 🔍 Key Learnings: Efficient searching in O(log n) Using low & high to narrow the range Finding correct position even if target is absent 🧠 Approach: Compare mid with target → move left/right → return index or insert position Consistency is key 🔥 #DSA #Java #CodingJourney #PlacementPreparation
To view or add a comment, sign in
-
-
#Day95 of #100DaysOfCode Extended the previous number-to-words program to handle multiple digits. The program takes a number as input and prints each digit in its word form. Focused on improving logic by combining loops, string conversion, and conditional handling. #Java #MiniProject #100DaysOfCode
To view or add a comment, sign in
-
-
Day 40 – Advanced Java Strings & Input Handling ☕ Today I revised advanced concepts related to Strings and input handling in Java. Topics covered: 🔹 Inbuilt String methods 🔹 Converting String to character array 🔹 Mutable vs Immutable Strings 🔹 Difference between StringBuilder and StringBuffer 🔹 Handling input using nextLine() with integers and strings 🔹 Understanding buffer issues in input handling 🔹 Converting mutable to immutable and vice versa 🔹 Difference between split() and StringTokenizer Revisiting these concepts helped me better understand how Java handles strings internally and how input operations can sometimes lead to unexpected issues if not handled properly. Strengthening core concepts step by step 🚀 #Day40 #JavaJourney #Strings #CoreJava #ProgrammingFundamentals
To view or add a comment, sign in
-
One of the most underrated skills in Java: 👉 Handling exceptions the RIGHT way. Early in my career, I used to either catch and ignore exceptions or throw them without any context. Bad idea. Over time, I realized that good exception handling is not just about fixing errors — it’s about making systems more reliable and easier to debug. Here’s what I follow now: ✔ Use meaningful exception messages ✔ Don’t swallow exceptions ✔ Log with proper context (user, request, trace) ✔ Create custom exceptions when needed ✔ Fail fast, but with clarity 💡 Insight: Users don’t care what exception occurred. They care that the system works reliably. Write code that fails well — so your system recovers better. #Java #ExceptionHandling #BestPractices #CleanCode #BackendDevelopment #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 35 of #100DaysOfCode — Java Stacks (Part 2) completed! 📚✅ Topics Covered ✅ 1️⃣ Valid Parentheses — check if brackets are balanced 2️⃣ Duplicate Parentheses — find redundant brackets in expression → ((a+b)+(c+d)) = false | (((a+b))+c) = true 3️⃣ Maximum Rectangular Area in Histogram → Classic stack problem — O(n) solution Key Takeaway 💡 Stack shines in bracket & histogram problems! Duplicate parentheses: if two consecutive ( without operator between → duplicate 35/100 done 🔥 #100DaysOfCode #Java #Stack #DSA #ApnaCollege #BuildInPublic #JavaDeveloper
To view or add a comment, sign in
-
-
Day 62 — LeetCode Progress (Java) Problem: Merge Strings Alternately Required: Given two strings word1 and word2, merge them by alternating characters, starting from word1. If one string is longer, append the remaining characters at the end. Idea: Use two pointers to traverse both strings simultaneously and build the result step by step. Approach: Initialize two pointers for both strings. Iterate while either string still has characters: Pick one character from word1 (if available) Then pick one from word2 (if available) Continue alternating until both strings are fully traversed. Time Complexity: O(n + m) Space Complexity: O(n + m) #LeetCode #DSA #Java #Strings #TwoPointers #Algorithms #CodingJourney #100DaysOfCode
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