𝗗𝗔𝗬 𝟭 – 𝗛𝗼𝘄 𝗝𝗮𝘃𝗮 𝗕𝗲𝗰𝗮𝗺𝗲 𝗣𝗹𝗮𝘁𝗳𝗼𝗿𝗺 𝗜𝗻𝗱𝗲𝗽𝗲𝗻𝗱𝗲𝗻𝘁 𝐋𝐞𝐭’𝐬 𝐬𝐭𝐚𝐫𝐭 𝐟𝐫𝐨𝐦 𝐳𝐞𝐫𝐨. 𝐁𝐞𝐟𝐨𝐫𝐞 𝐉𝐚𝐯𝐚... 𝐛𝐞𝐟𝐨𝐫𝐞 𝐜𝐨𝐝𝐞... 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗮 𝗽𝗿𝗼𝗴𝗿𝗮𝗺? A program is simply a set of instructions. 𝗪𝗵𝗮𝘁 𝗶𝘀 𝘀𝗼𝗳𝘁𝘄𝗮𝗿𝗲? A collection of programs designed to solve a problem. 𝗡𝗼𝘄 𝗵𝗲𝗿𝗲’𝘀 𝘁𝗵𝗲 𝗿𝗲𝗮𝗹 𝗾𝘂𝗲𝘀𝘁𝗶𝗼𝗻: If we write instructions in English-like code… 𝐇𝐨𝐰 𝐝𝐨𝐞𝐬 𝐚 𝐦𝐚𝐜𝐡𝐢𝐧𝐞 𝐮𝐧𝐝𝐞𝐫𝐬𝐭𝐚𝐧𝐝 𝐢𝐭? Machines only understand 𝗯𝗶𝗻𝗮𝗿𝘆 - 𝟬𝘀 𝗮𝗻𝗱 𝟭𝘀. So somewhere, our human-readable code must be translated into machine-understandable instructions. Most languages use: → 𝗔 𝗰𝗼𝗺𝗽𝗶𝗹𝗲𝗿 or → 𝗔𝗻 𝗶𝗻𝘁𝗲𝗿𝗽𝗿𝗲𝘁𝗲𝗿 𝗝𝗮𝘃𝗮 𝘂𝘀𝗲𝘀 𝗯𝗼𝘁𝗵. And that’s where the story gets interesting. 𝗪𝗵𝗲𝗻 𝘄𝗲 𝘄𝗿𝗶𝘁𝗲 𝗮 𝗝𝗮𝘃𝗮 𝗽𝗿𝗼𝗴𝗿𝗮𝗺: 𝗦𝘁𝗲𝗽 𝟭: The javac compiler (from JDK) converts our .java file into a .class file. This .class file contains 𝗯𝘆𝘁𝗲𝗰𝗼𝗱𝗲. 𝘽𝙮𝙩𝙚𝙘𝙤𝙙𝙚 𝙞𝙨 𝙣𝙤𝙩 𝙝𝙪𝙢𝙖𝙣 𝙡𝙖𝙣𝙜𝙪𝙖𝙜𝙚. 𝙄𝙩’𝙨 𝙣𝙤𝙩 𝙧𝙖𝙬 𝙢𝙖𝙘𝙝𝙞𝙣𝙚 𝙘𝙤𝙙𝙚 𝙚𝙞𝙩𝙝𝙚𝙧. 𝙄𝙩’𝙨 𝙖𝙣 𝙞𝙣𝙩𝙚𝙧𝙢𝙚𝙙𝙞𝙖𝙩𝙚 𝙡𝙖𝙣𝙜𝙪𝙖𝙜𝙚 𝙙𝙚𝙨𝙞𝙜𝙣𝙚𝙙 𝙨𝙥𝙚𝙘𝙞𝙛𝙞𝙘𝙖𝙡𝙡𝙮 𝙛𝙤𝙧 𝙨𝙤𝙢𝙚𝙩𝙝𝙞𝙣𝙜 𝙘𝙖𝙡𝙡𝙚𝙙 𝙩𝙝𝙚 𝙅𝙑𝙈. Now enters the hero: 𝗝𝗩𝗠 (Java Virtual Machine) The JVM reads the bytecode and converts it into machine-level instructions for the specific operating system it is running on. 𝗛𝗲𝗿𝗲’𝘀 𝘁𝗵𝗲 𝗽𝗼𝘄𝗲𝗿𝗳𝘂𝗹 𝗽𝗮𝗿𝘁: The same .class file can run on Windows, Linux, or Mac - as long as that system has 𝗶𝘁𝘀 𝗼𝘄𝗻 𝗝𝗩𝗠. That’s why Java is called: 𝗣𝗹𝗮𝘁𝗳𝗼𝗿𝗺 𝗜𝗻𝗱𝗲𝗽𝗲𝗻𝗱𝗲𝗻𝘁 (Write Once, Run Anywhere) Security, huge libraries, built-in APIs, memory management - all of that matters. 𝗕𝘂𝘁 𝘁𝗵𝗶𝘀 𝗮𝗿𝗰𝗵𝗶𝘁𝗲𝗰𝘁𝘂𝗿𝗲? This is what made Java revolutionary. 𝗧𝗼𝗺𝗼𝗿𝗿𝗼𝘄 (𝗗𝗮𝘆 𝟮): We’ll break down: • What exactly is JDK, JRE, JVM? • How they relate to each other • And what actually happens when you run 𝙹𝙰𝚅𝙰 𝙷𝙴𝙻𝙻𝙾𝚆𝙾𝚁𝙻𝙳 𝙏𝙝𝙞𝙨 𝙞𝙨 𝙟𝙪𝙨𝙩 𝙩𝙝𝙚 𝙗𝙚𝙜𝙞𝙣𝙣𝙞𝙣𝙜. Notes credit goes to my mentor Banti Chouhan sir 🥹🙏🏻 #Java #Backend #Programming #LearnInPublic #Day1
Java Indentent: Understanding Java Programs and JVM
More Relevant Posts
-
Imagine this situation. You and your friend are working on a 𝐬𝐡𝐚𝐫𝐞𝐝 𝐰𝐡𝐢𝐭𝐞𝐛𝐨𝐚𝐫𝐝. You write a number on the board. Your friend reads it. Simple, right? But now imagine both of you are working 𝐢𝐧 𝐝𝐢𝐟𝐟𝐞𝐫𝐞𝐧𝐭 𝐫𝐨𝐨𝐦𝐬 with 𝐲𝐨𝐮𝐫 𝐨𝐰𝐧 𝐜𝐨𝐩𝐢𝐞𝐬 𝐨𝐟 𝐭𝐡𝐞 𝐛𝐨𝐚𝐫𝐝. You update your board. But your friend still sees the 𝐨𝐥𝐝 𝐯𝐚𝐥𝐮𝐞. This is exactly what can happen in 𝗺𝘂𝗹𝘁𝗶𝘁𝗵𝗿𝗲𝗮𝗱𝗲𝗱 𝗝𝗮𝘃𝗮 𝗽𝗿𝗼𝗴𝗿𝗮𝗺𝘀. Each thread may work with its 𝐨𝐰𝐧 𝐜𝐚𝐜𝐡𝐞𝐝 𝐜𝐨𝐩𝐲 𝐨𝐟 𝐯𝐚𝐫𝐢𝐚𝐛𝐥𝐞𝐬 instead of the shared memory. And that’s where the 𝗝𝗮𝘃𝗮 𝗠𝗲𝗺𝗼𝗿𝘆 𝗠𝗼𝗱𝗲𝗹 (𝗝𝗠𝗠) comes in. What is the Java Memory Model? The 𝗝𝗮𝘃𝗮 𝗠𝗲𝗺𝗼𝗿𝘆 𝗠𝗼𝗱𝗲𝗹 defines how: • Threads interact with memory • Changes made by one thread become visible to others • The JVM handles caching and reordering Without rules like this, concurrent programs would behave unpredictably. 𝐓𝐡𝐞 𝐕𝐢𝐬𝐢𝐛𝐢𝐥𝐢𝐭𝐲 𝐏𝐫𝐨𝐛𝐥𝐞𝐦 Example: class FlagExample { static boolean running = true; public static void main(String[] args) { new Thread(() -> { while (running) { // waiting } System.out.println("Thread stopped"); }).start(); running = false; } } You might expect the thread to stop immediately. But sometimes 𝗶𝘁 𝗸𝗲𝗲𝗽𝘀 𝗿𝘂𝗻𝗻𝗶𝗻𝗴 𝗳𝗼𝗿𝗲𝘃𝗲𝗿. Why? Because the thread may keep reading a 𝗰𝗮𝗰𝗵𝗲𝗱 𝘃𝗮𝗹𝘂𝗲 𝗼𝗳 𝗿𝘂𝗻𝗻𝗶𝗻𝗴. It never sees the update. The Fix → 𝐯𝐨𝐥𝐚𝐭𝐢𝐥𝐞 volatile static boolean running = true; Now Java guarantees: • Updates are visible to all threads • Threads read the latest value from memory 𝐯𝐨𝐥𝐚𝐭𝐢𝐥𝐞 ensures 𝘃𝗶𝘀𝗶𝗯𝗶𝗹𝗶𝘁𝘆, not locking. 𝐊𝐞𝐲 𝐈𝐝𝐞𝐚 Multithreading problems are not always about race conditions. Sometimes the issue is simply: • Threads not seeing the same data. Today was about understanding: • Why threads may see 𝗱𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝘁 𝘃𝗮𝗹𝘂𝗲𝘀 • What the 𝗝𝗮𝘃𝗮 𝗠𝗲𝗺𝗼𝗿𝘆 𝗠𝗼𝗱𝗲𝗹 controls • How 𝐯𝐨𝐥𝐚𝐭𝐢𝐥𝐞 ensures 𝘃𝗶𝘀𝗶𝗯𝗶𝗹𝗶𝘁𝘆 Concurrency is not only about 𝗿𝘂𝗻𝗻𝗶𝗻𝗴 𝘁𝗵𝗶𝗻𝗴𝘀 𝗳𝗮𝘀𝘁𝗲𝗿. It’s also about 𝗺𝗮𝗸𝗶𝗻𝗴 𝘀𝘂𝗿𝗲 𝗲𝘃𝗲𝗿𝘆 𝘁𝗵𝗿𝗲𝗮𝗱 𝘀𝗲𝗲𝘀 𝘁𝗵𝗲 𝘀𝗮𝗺𝗲 𝗿𝗲𝗮𝗹𝗶𝘁𝘆. #Java #JavaConcurrency #JavaMemoryModel #Multithreading #SoftwareEngineering #LearningInPublic #Programming
To view or add a comment, sign in
-
-
Day 11 of Java, Now My Code Is Reusable & Smart 🧠 Today felt powerful. Because I learned something that separates beginners from real programmers… 👉 Methods. Instead of writing the same code again and again, we create reusable blocks. returnType methodName(parameters) { } Simple structure. Massive impact. 🔥 Parameters & Return Types Input goes in. Output comes out. Clean. Structured. Efficient. ⚡ Method Overloading Same method name. Different parameters. sum(int a, int b) sum(double a, double b) Same intention. Different behavior. That’s flexibility. 🔁 Recursion This one was different. A method calling… itself. But with one strict rule: 👉 Always have a base case. No base case = infinite loop = chaos 😅 Big realization today? Methods make code modular. Overloading makes it flexible. Recursion makes it powerful. Day 11 and now my programs are not just running… they’re structured. Consistency mode: ON 🚀🔥 Big thanks to Aditya Tandon sir and Rohit Negi sir...🙌🏻 #Java #CoreJava #Programming #LearningJourney #Developers #BuildInPublic #DailyLearning
To view or add a comment, sign in
-
-
♻️ Why should you always close Scanner in Java? Scanner is used to read input, from the console, a file, or a stream. But a lot of beginners (including me, early on) never bother closing it after use. Here's why that's a problem: ->it holds onto system resources even after your program is done with them ->for file-based Scanners, it can lock the file or cause data not to be flushed properly ->in larger programs, unclosed Scanners can quietly lead to resource leaks The fix is simple, either call: ✔️ sc.close() at the end ✔️ or use a try-with-resources block so Java closes it automatically While practicing Java basics, I realized the code worked either way… but one way was responsible, and the other wasn't. That's something no compiler warning will tell you. Writing correct code and writing clean, responsible code are two different things. Learning the difference early makes you a better developer. Learning in public, improving step by step 🤍 #Java #ResourceManagement #LearningInPublic #Programming
To view or add a comment, sign in
-
Most beginners focus on syntax. But Java made me realize something else matters more: 𝗦𝘁𝗿𝘂𝗰𝘁𝘂𝗿𝗲. You can write code that works… or you can write code that 𝙨𝙘𝙖𝙡𝙚𝙨 𝙖𝙣𝙙 𝙢𝙖𝙠𝙚𝙨 𝙨𝙚𝙣𝙨𝙚. This week, one idea really stuck with me: → 𝗚𝗼𝗼𝗱 𝗰𝗼𝗱𝗲 𝗶𝘀 𝗻𝗼𝘁 𝗷𝘂𝘀𝘁 𝘄𝗿𝗶𝘁𝘁𝗲𝗻. 𝗜𝘁’𝘀 𝗱𝗲𝘀𝗶𝗴𝗻𝗲𝗱. Things I’m starting to understand: • Why 𝗰𝗹𝗮𝘀𝘀𝗲𝘀 exist beyond just “grouping code” • How 𝗲𝗻𝗰𝗮𝗽𝘀𝘂𝗹𝗮𝘁𝗶𝗼𝗻 prevents future mess • Why 𝗿𝗲𝗮𝗱𝗮𝗯𝗶𝗹𝗶𝘁𝘆 > 𝗰𝗹𝗲𝘃𝗲𝗿 𝘀𝗵𝗼𝗿𝘁𝗰𝘂𝘁𝘀 • How 𝘀𝗺𝗮𝗹𝗹 𝗱𝗲𝘀𝗶𝗴𝗻 𝗱𝗲𝗰𝗶𝘀𝗶𝗼𝗻𝘀 affect everything later At first, it felt restrictive. Too many rules. Too much structure. But now I see — those “rules” are what make systems 𝗿𝗲𝗹𝗶𝗮𝗯𝗹𝗲. Still early in my journey, but this changed how I think. 𝗖𝘂𝗿𝗶𝗼𝘂𝘀 — 𝘄𝗵𝗮𝘁’𝘀 𝗼𝗻𝗲 𝗰𝗼𝗻𝗰𝗲𝗽𝘁 𝘁𝗵𝗮𝘁 𝗰𝗵𝗮𝗻𝗴𝗲𝗱 𝘁𝗵𝗲 𝘄𝗮𝘆 𝘆𝗼𝘂 𝗰𝗼𝗱𝗲? #java #programming #tech
To view or add a comment, sign in
-
-
Starting Java from scratch — and it already feels different. Today marks Day 01 of my journey towards becoming a Backend Engineer. I started with the basics of Java, but even the fundamentals gave a clear idea of how structured and powerful this language is. Here’s what I covered today: – What is Java & how it works – JVM (Java Virtual Machine), JDK, and JRE – Setting up the environment & extensions – Variables & Data Types – Typecasting (implicit & explicit) – Arithmetic & Logical Operators What stood out to me was understanding how Java is not just a language, but a complete ecosystem — especially the role of JVM in making Java platform-independent. Also, coming from C++, I could already feel the shift toward more structured and object-oriented thinking. Starting again from basics might feel slow, but I believe strong foundations are what make everything else easier later. 📍 This is part of my #BecomingABackendEngineer journey — building step by step, concept by concept. Also continuing my #DSAToMLJourney alongside. If you’ve worked with Java, what’s one concept I should focus on early? #Java #BackendDevelopment #LearningInPublic #StudentDeveloper #ConsistencyIsKey #Programming #TechJourney #BecomingABackendEngineer #DSAToMLJourney
To view or add a comment, sign in
-
-
Most developers get this wrong. Do you? 🛑 Early in my Java journey, I thought inheritance was a feature to use freely. The more you extended, the more reusable the code, right? Wrong. Uncontrolled inheritance creates hierarchies nobody can reason about. And Java had no clean answer for it — until sealed classes. ━━━━━━━━━━━━━━━━━━━━━━━━━ Sealed Classes, introduced in Java 17, let you define exactly which classes are permitted to extend yours. No surprises. No rogue subclasses. Just clean, intentional design. public sealed class Shape permits Circle, Rectangle, Triangle {} Each permitted subclass must be one of: → final — no further extension → sealed — further restricted with its own permits → non-sealed — open again by choice And the bonus? Exhaustive pattern matching with switch. The compiler knows every possible subtype. You get compile-time safety for free. ━━━━━━━━━━━━━━━━━━━━━━━━━ I’ve written a full breakdown — how sealed classes work, the rules, and real use cases. Read it here 👇 https://lnkd.in/gsN6Dp7j Have you used sealed classes in your projects? I’d love to hear how! #Java #Java17 #Coding #SoftwareDevelopment #TechCommunity #LearningInPublic #SealedClasses #BackendDevelopment #SoftwareEngineering #CleanCode #OOP
To view or add a comment, sign in
-
-
I wrote about the Predicate interface to provide a standardized way to evaluate conditions. This powerful tool addresses the need for functional programming constructs in Java, allowing developers to create more readable and maintainable code. Key concepts covered in the article include: - Why Java Introduced Predicate - What Problem Did Predicate Solve? - Real Examples - Use Cases I hope this article will be helpful for those looking to deepen their understanding of Java predicates and their applications in real-world scenarios.
To view or add a comment, sign in
-
Read a sensor value. Save it to a database. In Python that's 4 lines. Java: 12. C#: 8. Go: 6. Each looks completely different. Each needs a developer who knows that specific stack. Developer leaves? New one prefers something else. Rewrite. The logic never changed. But the implementation is tied to whoever wrote it. That's what visual development actually solves. Not "easier." Independent. #SoftwareArchitecture #NoCode #Manufacturing
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