Day 12 & 13 A Journey with Edunet Foundation and Fayaz S Nested for loop:- ✒️A Nested For Loop in java is a for loop placed inside the body of another for loop ✒️The structure allows for multiple levels of iteration and is commonly used for tasks. Syntax:- for(initialization; condition; increment/ decrement){ for( initialization; condition; increment/decrement){ } } Day13:- Break and Continue, Methods in Java:- Break:- ✒️Break immediately terminates the loop or switch ✒️Control jumps to the statment after the loop/switch Ex:- for(int i = 0; i<=10; i++) { if(i==3) { break; } System.out.println(i); } Continue:- ✒️ Skips the current iteration and continuous with the next ✒️Control jumps to the next iteration of the loop. Ex:- for(int i=1; i<=10; i++) { if(i==3) { continue; } System.out.println(i); } Methods in Java:- ✒️Method in java is block of code that perform a specific tasks. ✒️Inseted of writing the same code again, we write it once inside a method a call it whenever needed. Syntax:- returntype methodName() { } #java #loops #corejava
Java Nested Loops and Break Continue Methods
More Relevant Posts
-
#TapAcademy #Java #Fullstackdeveloment #Strings Strings in Java are used to store and handle text data. They are created using double quotes. For example, String text = "Hello, World!". Java offers many useful string methods, such as concat(), substring(), and toUpperCase(). You can compare, join, and format strings with these built-in methods. Strings are commonly used for managing text input, output, and data processing in programs.
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
-
-
♻️ 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
-
-
How the JVM Works (Simple Breakdown) We compile and run Java code every day, but what actually happens inside the JVM? Here’s the flow: 1. Build (Compilation) javac converts your .java code into bytecode (.class). This bytecode is platform-independent. 2. Load The JVM loads classes only when needed using class loaders: Bootstrap → core Java classes Platform → extensions System → your application 3. Link Before execution: Verify → checks bytecode safety Prepare → allocates memory for static variables Resolve → converts references into memory addresses 4. Initialize Static variables get their values and static blocks run (only once). 5. Memory Heap & Method Area → shared Stack & PC Register → per thread Garbage Collector manages memory automatically. 6. Execute Interpreter runs bytecode JIT compiler converts frequently used code into native code 7. Run Your program runs using a mix of interpreted and compiled code, improving performance over time. Dhee Coding Lab Sanjay Raghuwanshi
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 16: Method References (:: operator) in Java A powerful feature introduced in Java 8 that makes your code cleaner and more readable 👇 🔹 What is Method Reference? 👉 Definition: A shorter way to refer to a method using :: instead of writing a lambda expression. 🔹 Why Use It? ✔ Reduces boilerplate code ✔ Improves readability ✔ Works perfectly with Streams & Functional Interfaces 🔹 Lambda vs Method Reference 👉 Using Lambda: list.forEach(x -> System.out.println(x)); 👉 Using Method Reference: list.forEach(System.out::println); ✨ Cleaner & simpler! 🔹 Types of Method References 1️⃣ Static Method Reference ClassName::staticMethod 2️⃣ Instance Method (of object) object::instanceMethod 3️⃣ Instance Method (of class) ClassName::instanceMethod 4️⃣ Constructor Reference ClassName::new 🔹 Examples ✔ Static: Math::max ✔ Instance: System.out::println ✔ Constructor: ArrayList::new 🔹 When to Use? ✔ When lambda just calls an existing method ✔ To make code shorter and cleaner ✔ With Streams and Functional Interfaces 💡 Pro Tip: If your lambda looks like 👉 (x) -> method(x) You can replace it with 👉 Class::method 📌 Final Thought: "Method Reference = Cleaner Lambda" #Java #MethodReference #Java8 #Streams #Programming #JavaDeveloper #Coding #InterviewPrep #Day16
To view or add a comment, sign in
-
-
💯 Deserialization During API Automation : An Important Interview question ✓ While working on API Automation, as a result of hitting API Request, we receive JSON response. ✓ JSON Response could be Simple and can be Complex too ~ If Simple, its easy to validate ~ if it is complex then it would be difficult to validate ❓❓What is the solution ✓ Solution is converting them in to Java Objects : This process is known as Deserialization ✓ Introduction: https://lnkd.in/gAqa5Dc4 👉 Different Techniques are there to convert JSON response to POJO (Java Objects) ✓ Object Mapper of Jackson Library https://lnkd.in/gS2B7zsv ✓ Gson object of GSON library https://lnkd.in/gCuSw7iY ✓ Rest Assured default as method Coming soon Also, after JDK 17, RECORD class is introduced which is like substitute for POJO classes and they are light weight Checkout 👇 RECORD : A Special class in Java, lighter than POJO: https://lnkd.in/gXBC4UFY Regards PrinceAutomationDestination
Introduction to Deserialization in Java | Important Interview topic
https://www.youtube.com/
To view or add a comment, sign in
-
Something small… but it changed how I think about Java performance. We often assume `substring()` is cheap. Just a slice of the original string… right? That was true **once**. 👉 In older Java versions, `substring()` shared the same internal char array. Fast… but risky — a tiny substring could keep a huge string alive in memory. 👉 In modern Java, things changed. `substring()` now creates a **new String with its own memory**. Same value ❌ Same reference ❌ Safer memory ✅ And this is where the real learning hit me: **Understanding behavior > memorizing APIs** Because in a real system: * Frequent substring operations = more objects * More objects = more GC pressure * More GC = performance impact So the question is not: “Do I know substring?” But: “Do I know what it costs at runtime?” That shift — from syntax to system thinking — is where growth actually starts. #Java #BackendEngineering #Performance #JVM #LearningJourney
To view or add a comment, sign in
-
Java 17 Feature: Record Classes What is a Record Class? A record class is mainly used to create DTOs (Data Transfer Objects) in a simple and clean way. Why DTOs? DTOs are used to transfer data: • Between services • From backend to frontend Key Features of Record Classes: Immutable by default (data cannot be changed after creation) Less code (no need to write getters, constructors, etc.) When you create a record, Java automatically provides: Private final fields All-arguments constructor Getter methods (accessor methods) toString(), equals(), hashCode() Example: public record Customer(int customerId, String customerName, long phone) {} Usage: Customer customer = new Customer(1011, "John", 9890080012L); System.out.println(customer.customerId()); Important Points: Record class is implicitly final Cannot extend other classes Internally extends java.lang.Record Can implement interfaces (normal or sealed) Can have static methods and instance methods Cannot have extra instance variables With Sealed Interface: public sealed interface UserActivity permits CreateUser, DeleteUser { boolean confirm(); } public record CreateUser() implements UserActivity { public boolean confirm() { return true; } } Before Java 17: We used Lombok to reduce boilerplate code. After Java 17: Record classes make code: Cleaner Shorter Easier to maintain #Java #Java17 #BackendDevelopment #FullStackDeveloper #Programming #SoftwareEngineering
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