Day 7 of #100DaysOfCode — Java is getting interesting ☕ Today I explored the Java Collections Framework. Before this, I was using arrays for everything. But arrays have one limitation — fixed size. 👉 What if we need to add more data later? That’s where Collections come in. 🔹 Key Learnings: ArrayList grows dynamically — no size worries Easy operations: add(), remove(), get(), size() More flexible than arrays 🔹 Iterator (Game changer) A clean way to loop through collections: hasNext() → checks next element next() → returns next element remove() → safely removes element 🔹 Concept that clicked today: Iterable → Collection → List → ArrayList This small hierarchy made everything much clearer. ⚡ Array vs ArrayList Array → fixed size ArrayList → dynamic size Array → stores primitives ArrayList → stores objects Still exploring: Set, Map, Queue next 🔥 Consistency is the only plan. Showing up every day 💪 If you’re also learning Java or working with Collections — let’s connect 🤝 #Java #Collections #ArrayList #100DaysOfCode #JavaDeveloper #LearningInPublic
Exploring Java Collections Framework with ArrayList
More Relevant Posts
-
Day 51-What I Learned In a Day (JAVA) Today I stepped into the next important concept in Java -Non-Static Members. Unlike static members, non-static members belong to an object, not the class. This means they require an instance of the class to be accessed. What are Non-Static Members? Non-static members include: • Non-static variables (instance variables) • Non-static methods • Constructors Key Understanding: 🔹 Instance Variables Each object has its own copy of variables. Changes in one object do not affect another. 🔹 Non-Static Methods These methods can directly access both static and non-static members. They require object creation to be called. 🔹 Object Creation is Mandatory !To access non-static members: ClassName obj = new ClassName(); Important Difference I Learned: • Static → Belongs to class (no object needed) • Non-Static → Belongs to object (object required) What I Realized Today: Understanding non-static members is crucial because real-world applications mainly work with objects. This concept is the base for Object-Oriented Programming (OOP). #Java #OOP #Programming #LearningJourney #DeveloperLife
To view or add a comment, sign in
-
Day 33/100 — Threads & Multithreading ⚡ Java can do multiple things at the same time using threads. Thread lifecycle: NEW → RUNNABLE → RUNNING → WAITING → TERMINATED 2 ways to create threads: // Method 1: extend Thread class MyThread extends Thread { public void run() { println("Running!"); } } new MyThread().start(); // NOT run()! // Method 2: Runnable lambda (preferred!) Thread t = new Thread(() -> println("Lambda thread!")); t.start(); Most important rule: ALWAYS call start() — NOT run()! → run() = normal method call (same thread) → start() = creates new thread and calls run() 3 things to remember: → Prefer Runnable over extending Thread → start() not run() → Multiple threads = race conditions possible! 🎯 Challenge: Create 3 threads that each print their name 5 times. Observe the interleaved output! #Java #Threads #Multithreading #CoreJava #100DaysOfJava #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 18 – Java Streams: Writing Cleaner & Smarter Code Today I started exploring Java 8 Streams—a powerful way to process collections. Instead of writing traditional loops: List<Integer> nums = Arrays.asList(1, 2, 3, 4, 5); for (int n : nums) { if (n % 2 == 0) { System.out.println(n); } } 👉 With Streams: nums.stream() .filter(n -> n % 2 == 0) .forEach(System.out::println); --- 💡 What I liked about Streams: ✔ More readable and expressive ✔ Encourages functional style programming ✔ Easy to chain operations (filter, map, reduce) --- ⚠️ Important insight: Streams don’t store data—they process data pipelines 👉 Also: Streams are lazy → operations execute only when a terminal operation (like "forEach") is called --- 💡 Real takeaway: Streams are not just about shorter code—they help write clean, maintainable logic when working with collections. #Java #BackendDevelopment #Java8 #Streams #LearningInPublic
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
-
-
Hello Connections, Post 18 — Java Fundamentals A-Z This one makes your code 10x cleaner. Most developers avoid it. 😱 Can you spot the difference? 👇 // ❌ Before Java 8 — verbose and painful! List<String> names = Arrays.asList( "Charlie", "Alice", "Bob" ); Collections.sort(names, new Comparator<String>() { @Override public int compare(String a, String b) { return a.compareTo(b); } }); 8 lines. Just to sort a list. 😬 // ✅ With Lambda — clean and powerful! Collections.sort(names, (a, b) -> a.compareTo(b)); // ✅ Done! // Even cleaner with method reference! names.sort(String::compareTo); // ✅ One liner! // Real example! transactions.stream() .filter(t -> t.getAmount() > 10000) // Lambda! .forEach(t -> System.out.println(t)); // Lambda! Lambda = anonymous function // Structure of a Lambda (parameters) -> expression // Examples () -> System.out.println("Hello") // No params (n) -> n * 2 // One param (a, b) -> a + b // Two params (a, b) -> { // Block body int sum = a + b; return sum; } Post 18 Summary: 🔴 Unlearned → Writing verbose anonymous classes for simple operations 🟢 Relearned → Lambda = concise anonymous function — write less do more! 🤯 Biggest surprise → Replaced 50 lines of transaction processing code with 5 lines using Lambdas! Have you started using Lambdas? Drop a λ below! #Java #JavaFundamentals #BackendDevelopment #LearningInPublic #SDE2 Follow along for more! 👇
To view or add a comment, sign in
-
-
🚀 Day 53 – Mastering ArrayDeque in Java Today I explored one of the most efficient data structures in Java Collections – ArrayDeque 🔥 📌 Key Learnings: 🔹 ArrayDeque is a resizable array-based Deque (Double Ended Queue) 🔹 Supports insertion & deletion from both ends (front & rear) 🔹 No indexing → cannot use get/set methods 🔹 No null values allowed (throws runtime exception) 🔹 Duplicates & heterogeneous data allowed 🔹 Faster than LinkedList due to no memory overhead ⚙️ Traversal Techniques: ✔ For-each loop ✔ Iterator ✔ Descending Iterator (reverse traversal) 💡 Why ArrayDeque? 👉 O(1) performance for add/remove operations 👉 Best choice for implementing: Stack (LIFO) Queue (FIFO) Deque 🧠 Big Takeaway: ArrayDeque = Fast + Memory Efficient + Flexible (Stack/Queue/Deque in one) Consistency is the key 🔑 — learning something new every day! #Java #DataStructures #ArrayDeque #JavaCollections #CodingJourney #100DaysOfCode #LearningDaily
To view or add a comment, sign in
-
-
🔥 Java Records — Cleaner code, but with important trade-offs I used to write a lot of boilerplate in Java just to represent simple data: Fields… getters… equals()… hashCode()… toString() 😅 Then I started using Records—and things became much cleaner. 👉 Records are designed for one purpose: Representing immutable data in a concise way. What makes them powerful: 🔹 Built-in immutability (fields are final) 🔹 No boilerplate for getters or utility methods 🔹 Compact and highly readable 🔹 Perfect for DTOs and API responses But here’s what many people overlook 👇 ⚠️ Important limitations of Records: 🔸 Cannot extend other classes (they already extend java.lang.Record) 🔸 All fields must be defined in the canonical constructor header 🔸 Not suitable for entities with complex behavior or inheritance 🔸 Limited flexibility compared to traditional classes So while Records reduce a lot of noise, they are not a universal replacement. 👉 They work best when your class is truly just data, not behavior. 💡 My takeaway: Good developers don’t just adopt new features—they understand where not to use them. ❓ Question for you: Where do you prefer using Records—only for DTOs, or have you explored broader use cases? #Java #AdvancedJava #JavaRecords #CleanCode #BackendDevelopment #SoftwareEngineering
To view or add a comment, sign in
-
Java Collections seem straightforward… until edge cases start showing up in real-world code. Here are a few more collection behaviors worth knowing 👇 • Null handling in collections HashMap allows one null key, Hashtable allows none — small difference, big impact. • contains() vs containsKey() Using the wrong one in Map can lead to incorrect checks. • Size vs Capacity (ArrayList) size() is actual elements, capacity is internal storage — confusion can lead to performance issues. • remove() ambiguity in List remove(1) removes by index, not value — use remove(Integer.valueOf(1)) for value. • equals() & hashCode() importance Custom objects in HashSet/HashMap need proper overrides or duplicates may appear. • Iteration order assumptions HashMap order is unpredictable — don’t rely on it unless using LinkedHashMap or TreeMap. • Immutable collections (List.of) They throw UnsupportedOperationException on modification — common runtime surprise. Small collection details like these often lead to big debugging sessions. #Java #BackendDevelopment #Programming
To view or add a comment, sign in
-
-
♻️ Ever wondered how Java manages memory automatically? Java uses Garbage Collection (GC) to clean up unused objects — so developers don’t have to manually manage memory. Here’s the core idea in simple terms 👇 🧠 Java works on reachability It starts from GC Roots: • Variables in use • Static data • Running threads Then checks: ✅ Reachable → stays in memory ❌ Not reachable → gets removed 💡 Even objects referencing each other can be cleaned if nothing is using them. 🔍 Different types of Garbage Collectors in Java: 1️⃣ Serial GC • Single-threaded • Best for small applications 2️⃣ Parallel GC • Uses multiple threads • Focuses on high throughput 3️⃣ CMS (Concurrent Mark Sweep) • Runs alongside application • Reduces pause time (now deprecated) 4️⃣ G1 (Garbage First) • Splits heap into regions • Balanced performance + low pause time 5️⃣ ZGC • Ultra-low latency GC • Designed for large-scale applications ⚠️ One important thing: If an object is still referenced (even accidentally), it won’t be cleaned → which can lead to memory issues. 📌 In short: Java automatically removes unused objects by checking whether they are still reachable — using different GC strategies optimized for performance and latency. #Java #Programming #JVM #GarbageCollection #SoftwareDevelopment #TechConcepts
To view or add a comment, sign in
-
-
🚀 **Day 4/30 – LeetCode Java Challenge** Today’s problem pushed me to think beyond basic comparisons and focus on **pattern-based validation**. Worked on a string problem where the key insight was separating characters based on **even and odd indices**, then comparing frequency distributions instead of direct string matching. 📊 **Result:** ✔️ Accepted (752/752 test cases) ⚡ Runtime: 5 ms (Beats 93.81%) 💾 Memory: Efficient (Beats 86.60%) 💡 **What actually mattered today:** * Brute force thinking won’t scale — pattern recognition does * Breaking a problem into smaller logical groups simplifies everything * Frequency arrays can outperform more complex data structures when used correctly Let’s be real: This wasn’t a hard problem, but the approach matters. If you miss the pattern, you overcomplicate it. If you see it early, the solution becomes clean and efficient. Day 4 done. Still building consistency, still sharpening fundamentals. Archana J E Bavani k Deepika Kannan Divya Suresh Hari priya B Devipriya R Harini B Bhavya B Kezia H Vaishnavi Janaki #LeetCode #Java #DSA #ProblemSolving #Consistency #30DaysOfCode
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
https://www.youtube.com/watch?v=q6z_UCBM5Ek&t=3720s