👋 Hii Connections 📌𝗚𝗮𝗿𝗯𝗮𝗴𝗲 𝗖𝗼𝗹𝗹𝗲𝗰𝘁𝗼𝗿 (𝗚𝗖) 𝗶𝗻 𝗝𝗮𝘃𝗮 ❓ 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗚𝗮𝗿𝗯𝗮𝗴𝗲 𝗖𝗼𝗹𝗹𝗲𝗰𝘁𝗼𝗿 (𝗚𝗖)? Garbage Collector (GC) is a part of JVM that automatically removes unused objects from Heap memory. ❓ 𝗪𝗵𝘆 𝗚𝗖 𝗶𝘀 𝗡𝗲𝗲𝗱𝗲𝗱? In C/C++ → Memory is manually freed using free() or delete() In Java → Memory allocation = new Memory deallocation = Automatic (by GC) Prevents: -> Memory leaks -> Dangling pointers -> Manual memory errors ❓ 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗛𝗲𝗮𝗽 𝗔𝗿𝗲𝗮? Heap is the runtime memory where objects and instance variables are stored. Heap is divided into: 1️⃣ Young Generation 2️⃣ Old Generation ❓ 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗬𝗼𝘂𝗻𝗴 𝗚𝗲𝗻𝗲𝗿𝗮𝘁𝗶𝗼𝗻? Young Generation is the part of the Heap memory where newly created objects are stored. -> Most objects are short-lived, so GC runs frequently here. -> Young Generation has: 1. Eden Space 2. Survivor S0 3. Survivor S1 ❓ 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗘𝗱𝗲𝗻 𝗦𝗽𝗮𝗰𝗲? All new objects are created here. Example: Student s = new Student(); // Stored in Eden ❓ 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗦𝘂𝗿𝘃𝗶𝘃𝗼𝗿 (𝗦𝟬 & 𝗦𝟭)? Stores objects that survive Minor GC One acts as 𝗙𝗿𝗼𝗺 𝗦𝗽𝗮𝗰𝗲, other as 𝗧𝗼 𝗦𝗽𝗮𝗰𝗲 After each Minor GC → they swap Object age increases If age reaches limit (~15) → moved to Old Generation ❓𝗪𝗵𝗮𝘁 𝗶𝘀 𝗢𝗹𝗱 𝗚𝗲𝗻𝗲𝗿𝗮𝘁𝗶𝗼𝗻? Old Generation is the part of the Heap memory where long-lived objects are stored. -> Cleaned by Major / Full GC. -> If memory not available → java.util.OutOfMemoryError 📌𝗚𝗖 𝗳𝗼𝗹𝗹𝗼𝘄𝘀 𝗠𝗦𝗖 𝗔𝗹𝗴𝗼𝗿𝗶𝘁𝗵𝗺! 1️⃣ Mark – Marks reachable objects 2️⃣ Sweep – Removes unreachable objects 3️⃣ Compact – Rearranges memory (removes gaps) Java learners 👉 Save it. Like it. Comment “JVM”. 🚀 🚀 Next post will be about Garbage Collection in Java - how JVM automatically manages memory! Follow and like to stay updated with the series 💙 #Java #GarbageCollection #100DaysOfCode
Garbage Collector (GC) in Java: Heap Memory and Generations
More Relevant Posts
-
🚀 DSA Journey – Day 4 (Java) Today I moved deeper into Functions in Java (Methods) and explored how Java handles memory and parameters internally. In Java, functions are called methods, and I understood the structure clearly: static returnType methodName(parameters) { // method body } 📘 What I learned today: 🔹 Pass by Value in Java Java is strictly pass by value. For primitive types (int, char, double, etc.) Only a copy of the value is passed. So swapping two numbers inside a method does NOT affect the original variables. For objects (arrays, strings, classes) A copy of the reference is passed. So modifying the object inside the method affects the original object. It is not pass by reference because Java does not expose raw pointers like C/C++. 🔹 Scoping & Shadowing Local variables exist only inside their block/method Class-level variables can be accessed across methods Shadowing happens when a local variable hides a class variable with the same name 🔹 Variable Arguments (Varargs) Using: datatype... v Allows passing multiple values Internally treated as an array Must always be the last parameter 🔹 Method Overloading Multiple methods with the same name but different parameters (Changing type or number of parameters) This improves readability and flexibility of code. Today’s session made me realize that understanding how methods behave internally is crucial before moving deeper into DSA. 📌 Next: Strengthening arrays and problem-solving. Step by step. Consistency over speed. #DSA #Java #LearningInPublic #Day4 #BTechStudent #AspiringSoftwareEngineer
To view or add a comment, sign in
-
🚀 Day 9 of Learning Java – Understanding Arrays from Memory Perspective Today’s lecture completely changed the way I look at arrays. Earlier, I thought arrays were just collections of elements. But today, I understood what actually happens inside memory and the JVM. 🧠💻 🔹 How elements are stored in an array Arrays store elements in contiguous memory locations. That means all elements are placed next to each other in memory — no gaps. 🔹 Why contiguous memory? Because it makes element access extremely fast. The system can calculate the memory address directly using indexing. 🔹 What happens when we write: new int[5]; Here’s what actually happens inside the JVM: • Memory is allocated in the Heap • Space for 5 integers is reserved • Each element is initialized with default value (0 for int) • A reference to that array is stored in the Stack So basically: 📌 Array object → Heap memory 📌 Reference variable → Stack memory 🔹 Stack vs Heap for Arrays Stack stores the reference (address). Heap stores the actual array data. 🔹 How indexing works When we access arr[2], the JVM calculates: base address + (index × size of data type) That’s why array access time is O(1) — constant time. No searching. No iteration. Direct memory calculation. ⚡ 🔹 Performance Understanding Because of contiguous memory and direct indexing: ✔ Fast access ✔ Better cache performance ✔ Predictable time complexity But resizing is costly — because memory block must be recreated. 💡 Biggest takeaway today: Arrays are not just data structures. They are memory blocks managed intelligently by the JVM. Understanding this makes problem-solving stronger and helps in writing optimized code. Grateful for such clear and deep explanations in every lecture. Special thanks to Aditya Tandon sir and Rohit Negi sir 🙌 Excited to continue this journey 🔥 #Java #LearningJourney #CoreJava #DataStructures #Programming #Day9
To view or add a comment, sign in
-
-
🚀 Day 50/100 – #JavaJourney Continuing the journey with a mix of DSA practice and Core Java learning. Today’s focus was revisiting some important LeetCode problems and strengthening Java fundamentals. 🧠 DSA Practice (LeetCode) 1️⃣ LC 1 – Two Sum (Hash Map Complement Approach) 2️⃣ LC 26 – Remove Duplicates from Sorted Array (Two Pointer Approach) 3️⃣ LC 35 – Search Insert Position (Linear / Binary Search Approach) 4️⃣ LC 27 – Remove Element (Two Pointer Approach) 5️⃣ LC 283 – Move Zeroes (Two Pointer + Swap / Write Approach) 6️⃣ LC 66 – Plus One Also progressing with Prefix Sum concepts, practicing problems like Subarray Range Sum and Maximum Subarray to better understand array patterns. 📚 Core Java Concepts Studied 1️⃣ Enums & Annotations 2️⃣ Functional Interfaces & Lambda Expressions 3️⃣ Exception Handling & Custom Exceptions 4️⃣ User Input Handling (BufferedReader & Scanner) 5️⃣ Multithreading Concepts (Threads, Runnable, Race Condition, Thread States) 📈 Key Takeaways • Revisiting classic problems helps reinforce important DSA patterns • Learning concepts like lambdas and multithreading adds deeper understanding of Java • Consistency with both DSA practice and Java fundamentals is helping me build stronger foundations 💻 Check out my work: 🔗 GitHub: https://lnkd.in/gGquYtVZ 🔗 LeetCode: https://lnkd.in/gaNyep3M Day 50 completed ✅ Halfway through the journey and still learning every day 🚀 #Java #DSA #LeetCode #CoreJava #Multithreading #Lambda #100DaysOfCode #CodingJourney #Consistency #ProblemSolving
To view or add a comment, sign in
-
🚀 Learning Update: Core Java – Encapsulation & Constructors 1️⃣ Understood Encapsulation practically, not just theoretically. 2️⃣ Learned how to protect data using the private access modifier. 3️⃣ Implemented controlled access using setters and getters. 4️⃣ Realized the importance of validating data inside setters (handling negative values, invalid inputs, etc.). 5️⃣ Implemented a real-world example using a Customer class with ID, Name, and Phone fields. 6️⃣ Learned about the shadowing problem when parameter names match instance variables. 7️⃣ Understood that local variables have higher priority inside methods. 8️⃣ Solved shadowing using the this keyword (currently executing object). 9️⃣ Gained clarity on constructors and how they are called during object creation. 🔟 Learned that constructors must have the same name as the class and do not have a return type. 1️⃣1️⃣ Understood the difference between default constructor, zero-parameterized constructor, and parameterized constructor. 1️⃣2️⃣ Learned that if we don’t create a constructor, Java automatically provides a default constructor. 1️⃣3️⃣ Explored constructor overloading and how Java differentiates constructors based on parameters. 1️⃣4️⃣ Understood the difference between constructors and methods (return type, calling time, naming rules). 1️⃣5️⃣ Gained better clarity on object creation flow, memory allocation, and execution order. Feeling more confident about explaining Encapsulation and Constructors clearly in interviews now! 💻🔥 #Java #CoreJava #OOPS #Encapsulation #Constructor #LearningJourney #PlacementPreparation TAP Academy
To view or add a comment, sign in
-
-
In college, I "learned" many programming languages. Python, Java, JavaScript, C. I touched them all. But touch is the right word. I never went deep. Flow control (loops, if-else), basic CRUD APIs; nothing beyond the surface. One such language was Go. I've been at Groww since my 3rd year of college, and somewhere around 85% of my work has been Java or JVM-based. And honestly? Java is a fantastic language for what it's designed for. Enterprise scale, batteries included, battle-tested for decades. I have deep respect for it. But Go has been quietly taking over. Its simplicity, built-in concurrency primitives, fast compile times, and lean runtime make it increasingly attractive for high-throughput backend services and infrastructure tooling. More teams are picking it up every year. We have a few Go services at Groww, and I recently had to work on one of them. Coming from a Java mental model (where I've spent nearly 4 years), the syntax and idioms felt foreign. Goroutines vs threads. No classes, no exceptions. Interfaces that are implicitly satisfied. Error handling via return values. I kept reaching for patterns that just don't exist the same way in Go. I asked Claude for help in understanding the differences. What came out of that conversation was something I thought was worth turning into a proper resource: a side-by-side reference for Java developers learning Go, mapping familiar Java concepts to their Go equivalents. So I built it. 21 guided sections, Java vs Go code comparisons, covering everything from the mental model shift to project layout. Claude helped me build the site itself. I'm genuinely interested in learning in public and building tools that help others learn. If you're a Java developer navigating Go (or vice versa), I hope this saves you a few hours of confusion. 🔗 Links in comments — deployed site + GitHub repo. The repo is open. If you spot something wrong or want to add a section, PRs and issues are very welcome. Would love the community's help in making it more complete and accurate. 🙏
To view or add a comment, sign in
-
🚀Data abstraction is the process of hiding certain details and showing only essential information to the user. Abstraction can be achieved with either abstract classes or interfaces (which you will learn more about in the next chapter). The abstract keyword is a non-access modifier, used for classes and methods: Abstract class: is a restricted class that cannot be used to create objects (to access it, it must be inherited from another class). Abstract method: can only be used in an abstract class, and it does not have a body. The body is provided by the subclass (inherited from). An abstract class can have both abstract and regular methods. An abstract class in Java is a special type of class that cannot be instantiated (you cannot create objects from it directly) and is meant to be extended (inherited) by other classes. It is declared using the abstract keyword. 🔹 In Simple Words Think of an abstract class as a blueprint for other classes. It defines: Some common properties (variables) Some common methods (with code) Some abstract methods (without code) that child classes must implement 🔹 Why Do We Use Abstract Classes? We use abstract classes when: ✨We want to provide common behavior to multiple related classes We want to force subclasses to implement certain methods We want partial abstraction (0–100%) What Can an Abstract Class Contain? An abstract class can have: ✨Normal methods (with body) These methods already have code. ✨Child classes can use them directly. Abstract methods (without body) ✨These methods only have declaration. Child classes must give their own implementation. Variables Like normal classes. Constructors Used when child class object is created. Special thanks to the Anand Kumar Buddarapu Saketh Kallepu Uppugundla Sairam #Java #AbstractClass #OOP #ObjectOrientedProgramming #JavaProgramming #CoreJava #ProgrammingBasics #CodingLife #LearnJava #SoftwareDevelopment 🚀💻✨
To view or add a comment, sign in
-
-
𝗦𝗶𝗺𝗽𝗹𝗲 𝗪𝗮𝘆 𝗧𝗼 𝗜𝗺𝗽𝗿𝗼𝘃𝗲 𝗬𝗼𝘂𝗿 𝗝𝗮𝘃𝗮 𝗦𝗸𝗶𝗹𝗹𝘀 I decided to improve my Java problem-solving skills by practicing coding problems for 7 days. I followed a structured approach covering numbers, recursion, arrays, and strings. Here's what I did each day: - Day 1: Basic number problems like reversing a number, palindrome number, and sum of digits - Day 2: Recursion and mathematical concepts like counting digits, Fibonacci series, and factorial - Day 3: Prime and special numbers like checking prime numbers and strong numbers - Day 4: Array basics like bubble sort, maximum element, and reversing an array - Day 5: Array rotations and duplicates like removing duplicates and left/right rotation - Day 6: String basics like reversing a string, palindrome string, and counting vowels - Day 7: Advanced string problems like anagram, first non-repeating character, and checking unique characters What I learned: - Improved logical thinking - Better understanding of time and space complexity - Learned difference between brute force and optimized approach - Strengthened recursion basics - Practiced two-pointer technique - Improved confidence in writing clean Java code I focused on mastering around 30 fundamental problems deeply. This gave me more clarity and confidence. Source: https://lnkd.in/geyEpYGv
To view or add a comment, sign in
-
DAY 16: CORE JAVA TAP Academy 🚀 Deep Dive into Java Strings: Memory, Methods, and Manipulation If you're learning Java, you quickly realize that Strings aren't just simple data types—they are objects with unique memory management rules! I’ve been brushing up on the fundamentals and mapped out some key concepts. Here’s a breakdown of what I’ve been diving into: 🧠 1. String Memory Management The difference between SCP (String Constant Pool) and the Heap is crucial for performance: * Direct Literals: Using "A" + "B" creates the string in the SCP. No duplicates allowed! * Variables/Objects: Concatenating variables (e.g., s1 + s2) or using the concat() method always creates a new object in the Heap. * The Result: Two strings can have the same value but different memory references. This is why we use .equals() for content and == for reference! 🛠️ 2. Essential String Methods Java provides a robust toolkit for string manipulation. Some of my favorites from today’s practice: * substring(start, end): To extract specific parts of a string. * indexOf() & lastIndexOf(): To track down character positions. * toCharArray() & split(): Perfect for breaking strings down for complex algorithms. ⚖️ 3. Mastering compareTo() Unlike .equals() which just gives a True/False, compareTo() returns an integer based on Lexicographical order: * Negative: s1 < s2 (comes before) * Positive: s1 > s2 (comes after) * Zero: They are a perfect match! Understanding these nuances is the first step toward writing memory-efficient Java code. #Java #Programming #CodingTips #SoftwareDevelopment #LearningToCode #TechCommunity #JavaStrings
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