🚀 Day 4/30 — Java Challenge Topic: Control Statements in Java Today I revised decision-making and looping statements. Types of Control Statements: ✔ if ✔ if-else ✔ switch ✔ for loop ✔ while loop ✔ do-while loop 💡 Key Learnings: • switch uses break to avoid fall-through • do-while executes at least once • Difference between break and continue • for vs while loops 🎯 Interview Questions: What are control statements? Difference between if and switch? for vs while? break vs continue? while vs do-while? Nested loops? Infinite loop? Fall-through in switch? Can switch use String? When to use switch? Follow my 30-Day Java Challenge for daily Java revision. #Java #JavaDeveloper #BackendDeveloper #LearningInPublic #30DaysChallenge #Freshers #Coding #SoftwareEngineer #JavaBasics
Java Control Statements Explained
More Relevant Posts
-
🚀 Day 5/30 — Java Challenge Topic: Arrays in Java Today I revised arrays — the foundation of problem solving. What is Array? Array is a collection of same type elements stored in contiguous memory locations. Types of Arrays: ✔ One-Dimensional Array ✔ Two-Dimensional Array ✔ Jagged Array 💡 Key Learnings: • Array index starts from 0 • Default values in arrays • Jagged array concept • arr.length vs arr.length() 🎯 Interview Questions: What is array? Advantages of array? What is 2D array? What is jagged array? Default values in array? Array index starts from? How to find array length? Array vs ArrayList? Can array store different types? Multidimensional array? Follow my 30-Day Java Challenge for daily Java revision. #Java #JavaDeveloper #DSA #Arrays #LearningInPublic #30DaysChallenge #Freshers #Coding #SoftwareEngineer
To view or add a comment, sign in
-
🚀 Day 5/30 — Java Challenge Topic: Arrays in Java Today I revised arrays — the foundation of problem solving. What is Array? Array is a collection of same type elements stored in contiguous memory locations. Types of Arrays: ✔ One-Dimensional Array ✔ Two-Dimensional Array ✔ Jagged Array 💡 Key Learnings: • Array index starts from 0 • Default values in arrays • Jagged array concept • arr.length vs arr.length() 🎯 Interview Questions: What is array? Advantages of array? What is 2D array? What is jagged array? Default values in array? Array index starts from? How to find array length? Array vs ArrayList? Can array store different types? Multidimensional array? Follow my 30-Day Java Challenge for daily Java revision. #Java #JavaDeveloper #DSA #Arrays #LearningInPublic #30DaysChallenge #Freshers #Coding #SoftwareEngineer
To view or add a comment, sign in
-
-
Day 1 of my Java Backend Journey focused on the foundational concept of the Collections Framework. Today I started revising and learning one of the most important concepts in Java: - Collections are used to store a group of objects efficiently. - Collections are preferred over arrays due to their dynamic size and flexibility. - There is a key difference between arrays and collections. - Understanding the distinction between Collection and Collections is crucial for interviews. - I explored the hierarchy of the Collection Framework. Topics covered: - List (ArrayList, LinkedList) - Set (HashSet, TreeSet) - Queue (PriorityQueue) - Map (HashMap, TreeMap) Key Takeaways: - Collections are dynamic, unlike arrays. - Collections store objects, utilizing wrapper classes like Integer. - The Map is part of the framework but does not extend Collection. - Iterable serves as the root interface for traversal. Real-world applications: - List for storing users/applicants. - Set for unique values, such as skills. - Queue for processing order. - Map for key-value mapping (ID to Data). Consistency matters more than perfection. I'm starting small but aiming big. #Java #BackendDevelopment #SpringBoot #Collections #LearningInPublic #Freshers #30DaysOfCode
To view or add a comment, sign in
-
Today I Learned – Exception Handling in Java Errors are part of every program… but a good developer knows how to handle them gracefully! Today I strengthened my understanding of Exception Handling in Java. 💡 What is Exception Handling? It is a mechanism to handle runtime errors so the program continues execution without crashing. 🔑 Why is it important? Without handling → Program crashes ❌ With handling → Program continues smoothly ✅ 🧠 5 Ways to Handle Exceptions (Easy to Remember) 👉 Try – Catch – Finally – Throw – Throws 1️⃣ try–catch → Handle errors safely 2️⃣ Multiple catch → Handle different errors 3️⃣ finally → Always executes (resource closing) 4️⃣ throw → Create exception manually 5️⃣ throws → Delegate exception to caller ⚡ Types of Exceptions ✔ Checked → Compile-time (must handle) ✔ Unchecked → Runtime (optional) #Java #JavaDeveloper #CoreJava #Programming #Coding #SoftwareDeveloper #Developers #CodingLife #100DaysOfCode #LearningJourney #ContinuousLearning #TechSkills #CareerGrowth #Upskilling #Freshers #JobReady #InterviewPreparation #TechCommunity #DevelopersOfLinkedIn #WomenWhoCode #CodeNewbie #ProgrammerLife #CodingJourney
To view or add a comment, sign in
-
-
#100daysofcodingchallenge - Day34 Question: Write a Java program to find the index of the last occurrence of a given element (k) in an array of integers. If the element is not found, print -1 Input: 8 2 5 6 4 7 9 5 3 5 Output: 6 #100daysofcodingchallenge #codingchallenge #day34 #corejava #ITjobs #freshers #softwarejobs #practicecoding #continuouslearning #learningcoding #problemsolving
To view or add a comment, sign in
-
-
Hello Connections, Post 16 — Java Fundamentals A-Z This one confuses freshers and seniors equally. 😱 Can you spot the bug? 👇 public void readFile(String path) { try { FileReader file = new FileReader(path); } catch (RuntimeException e) { System.out.println("Error!"); // 💀 Won't compile! } } The bug? FileNotFoundException is a checked exception. RuntimeException is unchecked. You MUST catch the right type! 💀 Here’s the difference 👇 // ✅ Checked — compiler FORCES you to handle! public void readFile(String path) throws IOException { FileReader file = new FileReader(path); // Must handle or declare — no choice! } // ✅ Unchecked — compiler doesn't care! public void divide(int a, int b) { int result = a / b; // ArithmeticException — no forced handling! } Post 16 Summary: 🔴 Unlearned → Catching RuntimeException for everything 🟢 Relearned → Checked = compiler forces handling, Unchecked = your responsibility! Have you ever been caught by this? Drop a ✅ below! Follow along for more! 👇 #Java #JavaFundamentals #BackendDevelopment
To view or add a comment, sign in
-
-
Day 2 of my Java Backend Journey focused on mastering the List interface and its implementations within Java Collections. Here’s what I learned: - **What is List?** - Stores elements in order (insertion order maintained) - Allows duplicate values - Supports index-based access - Simple understanding: List is like a numbered collection (0, 1, 2...) - **Real-world usage:** - Chat messages - Student attendance - Order history - **Key Implementations of List:** - ArrayList - LinkedList - Vector - Stack **Deep Dive:** - **ArrayList:** - Dynamic array (resizable) - Fast access → O(1) - Slower insert/delete → O(n) - Best when: frequent reading & index access - **LinkedList:** - Doubly linked list structure - Faster insert/delete compared to ArrayList - Slower access → O(n) - Best when: frequent modifications - **Vector:** - Thread-safe version of ArrayList - Slower due to synchronization - Mostly used in legacy systems - **Stack:** - Follows LIFO (Last In First Out) - Used in undo operations, recursion, expression evaluation **ArrayList vs LinkedList:** - ArrayList → fast access, slow modification - LinkedList → slow access, fast modification **Key Takeaways:** - Choose the right List implementation based on use case - ArrayList is most commonly used in real projects - Understanding internal workings is important for interviews Consistency is key — small steps every day! #Java #BackendDevelopment #JavaCollections #LearningInPublic #Freshers #30DaysOfCode
To view or add a comment, sign in
-
🚨 As a fresher, I recently learned something interesting about Java Collections 👇 While working with lists, I encountered a common issue: 👉 ConcurrentModificationException 💥 Problem: List<Integer> list = new ArrayList<>(List.of(1, 2, 3)); for (Integer n : list) { if (n == 3) { list.remove(n); // ❌ Throws ConcurrentModificationException } } 🔍 Why does this happen? Java collections internally use a mechanism called modCount (modification count). When an iterator is created, it stores a snapshot of this value If the list is modified directly (like list.remove()), modCount changes But the iterator’s expected value remains the same 👉 This mismatch leads to ConcurrentModificationException (This is known as Java’s Fail-Fast behavior) ✅ Correct Approach: Use Iterator to safely modify the collection: List<Integer> list = new ArrayList<>(List.of(1, 2, 3)); Iterator<Integer> it = list.iterator(); while (it.hasNext()) { Integer n = it.next(); if (n == 3) { it.remove(); // ✅ Safe removal } } System.out.println(list); // [1, 2] 💡 Key Takeaways: ✔ Don’t modify a collection directly while iterating ✔ Use iterator.remove() for safe updates ✔ Understand Fail-Fast behavior in Java collections ✔ Knowing internals like modCount helps in debugging & interviews ✨ Bonus (Java 8+): list.removeIf(n -> n == 3); Have you faced this issue before? How did you debug it? Let’s discuss 👇 #Java #CoreJava #JavaDeveloper #Programming #Coding #SoftwareDevelopment #Collections #Iterator #ListIterator #JavaCollections #ConcurrentModificationException #FailFast #Debugging #InterviewPreparation #LearnJava #Developers #TechCommunity #Freshers
To view or add a comment, sign in
-
Day 6 of my Java Learning Journey 🚀 Today I focused on understanding how Java interacts with external data: ✔️ File Handling (reading and writing files) ✔️ Basic concepts of database connectivity (JDBC) ✔️ Practiced simple programs to handle file input and output Learning how applications store and retrieve data is an important step toward building real-world software. Taking small steps every day and staying consistent 💻 #Java #LearningJourney #Coding #SoftwareDevelopment #Freshers #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