During my Full Stack Java training at Codegnan IT Solutions, I recently learned about one of the most essential parts of any Java program — the public static void main(String[] args) method. It might seem like just a single line of code, but every keyword in it plays a crucial role in how Java runs your program 👇 🔹 public The public keyword makes the main() method accessible from anywhere. Since the JVM (Java Virtual Machine) needs to start the program from outside the class, the method must be declared public. 🔹 static static lets the JVM call this method without creating an object. When the program first runs, no objects exist yet — so the method needs to be accessible in a static way. 🔹 void This means the method doesn’t return any value. After the instructions inside it execute, the program simply finishes. 🔹 main This is the entry point of every Java program. The JVM specifically looks for a method named main() to begin execution — changing the name would stop your program from running. 🔹 (String[] args) This part allows the program to receive input from the command line. args is an array of strings that stores those command-line arguments. 💡 In a nutshell: public static void main(String[] args) is not just a formality — it’s how the JVM connects with and runs your Java code. Each keyword serves a specific purpose to make program execution possible. A big thanks to Anand Kumar Buddarapu Sir for explaining these concepts so clearly and making learning Java so enjoyable! 🙏 #Java #Programming #FullStackDevelopment #Codegnan #LearningJava #TechTraining #CodingJourney #SoftwareDevelopment #JavaLearning
Understanding the public static void main() method in Java
More Relevant Posts
-
As part of my Full Stack Java training at Codegnan IT Solutions, I recently explored one of the most fundamental and important parts of Java — the public static void main(String[] args) method. It might look like a long line of code, but every keyword here has a specific meaning and purpose. Let’s break it down 👇 🔹 public The keyword public makes the main() method accessible from anywhere. The JVM (Java Virtual Machine) needs to access this method from outside the class to start program execution — that’s why it must be declared public. 🔹 static The keyword static allows the JVM to call the method without creating an object of the class. This is essential because when the program starts, no objects exist yet — so the method must be callable in a static way. 🔹 void The keyword void specifies that the main() method does not return any value. Once the code inside it executes, the program simply terminates. 🔹 main This is the method name recognized by the JVM as the entry point of any Java application. If you change this name, the program won’t start because the JVM looks specifically for a method named main. 🔹 (String[] args) This part allows the program to accept input from the command line when it starts. args is an array of String objects that stores those command-line arguments. 💡 In Summary: public static void main(String[] args) is not just a rule — it’s the gateway through which the JVM interacts with your code. Each keyword ensures that Java can locate, access, and run your program efficiently. A big thank you to Anand Kumar Buddarapu Sir for explaining every concept so clearly! 🙏 #Java #Programming #FullStackDevelopment #Codegnan #LearningJava #TechTraining #CodingJourney #SoftwareDevelopment #JavaLearning
To view or add a comment, sign in
-
-
🌈 Day 24 of My Java Learning Journey 🎊🏅 🔥 Access Modifiers in Java The Gatekeepers of Your Code! 🚪☕ Ever wondered how Java controls who can access what in your code? That’s where Access Modifiers step in they’re like security guards 🧱 standing at different levels of your Java application. Let me explain simply 👇 Java has four main access levels: 🔹 public - Accessible from anywhere in the project. 🔹 protected - Accessible within the package and by subclasses (even in other packages). 🔹 default (no keyword) - Accessible only within the same package. 🔹 private - Accessible only inside the same class. 💡 When I first started coding, I made every class and variable public 😅. One day, a bug from another class changed my variable’s value that’s when I realized the power of access control! ✨ The beauty of access modifiers? They help keep your code secure, modular, and easy to maintain. 🔚 Keep learning, keep securing your code that’s how you grow from writing code to building systems. 💻💪 #Java #AccessModifiers #JavaLearning #CodingJourney #BackendDevelopment #JavaDeveloper #OOP #CodeSecurity #LearnInPublic #100DaysOfCode #TechCareer #ProgrammingTips #SoftwareEngineering #DevelopersJourney #CodeBetter #JavaProgramming #CleanCode #SpringBoot #BackendEngineer #Maang #Consistency #Motivation #Hustle #Google #CarrierGoal
To view or add a comment, sign in
-
-
#DAY54 of Learning Java Fullstack... Today Let's learn about the inner classes.... What are the inner classes? 💡 Inner Classes in Java ★ An Inner Class in Java is a class defined inside another class. ★ It helps in grouping classes logically and improving encapsulation. ★Inner classes can access the private members of the outer class. 🔹 Types of Inner Classes in Java There are 4 main types of inner classes: ➤ Non-static Inner Class (Member Inner Class) Defined inside another class but outside any method and without the static keyword. ➤ Static Nested Class Declared inside another class using the static keyword. It does not require an object of the outer class to be created. ➤ Local Inner Class Declared inside a method, constructor, or block. It is local to that block and cannot be accessed outside it. ➤ Anonymous Inner Class A class without a name that is used to instantiate objects with certain modifications. #Java #InnerClasses #CoreJava #JavaProgramming #Coding #JavaDeveloper #ProgrammingConcept #LearnJava #CodeWithJava #TechLearning 10000 Coders Gurugubelli Vijaya Kumar
To view or add a comment, sign in
-
🌟 Day 18 of My Java Learning Journey: Understanding the 'final' Keyword! 🚀 Hey everyone! 👋 Today, I'm excited to share what I've learned about the 'final' keyword in Java. It's a simple but important tool that helps make your code safer and easier to manage. 🔒 First, for variables: 📊 Using 'final' makes them constants, meaning their value can't change once set. For example, you could declare a number like PI as final, so it stays the same and avoids mistakes in calculations. ✅ For methods: 🛡️ 'final' stops subclasses from overriding (changing) the method, protecting your original code from being altered unexpectedly. For classes: 🔐 'final' prevents the class from being inherited, keeping its design intact for security or to avoid complications. I've tried this in small projects, like a settings class where final ensures nothing changes at runtime. 😊 It feels great because it reduces errors and makes code more reliable. Why is this useful? 💡 'final' helps create stable, maintainable programs. If you're learning Java, give it a try—it's a key part of writing good code! Have you used 'final' in your projects? Share your experiences in the comments! 🔥 #Java #Programming #CodingJourney #SoftwareDevelopment #LearnToCode"
To view or add a comment, sign in
-
💡 Why Java Forces extends First, Then implements In Java, a class can inherit from only one superclass (using extends) and implement multiple interfaces (using implements). The correct order is always: Example : public class Child extends Parent implements Interface 1, Interface2 { } 🔹 1. Defines Identity First (extends) : extends shows who the class really is — it forms the main inheritance chain. 🔹 2. Adds Abilities Later (implements) : implements shows what the class can do — it adds extra capabilities from interfaces. 🔹 3. Compiler Rule When Java compiles your class: It must first build the class hierarchy (who extends whom). Then it checks the interfaces and ensures all abstract methods are implemented. Special Thanks : Special thanks to my mentors for guiding me in understanding Java OOP concepts and helping me grow as a developer. Your mentorship means a lot! #Java #OOP #Inheritance #Extends #Implements #Learning #Mentorship #Codegnan
To view or add a comment, sign in
-
-
🚀 Day 49 of 180 – Java Full Stack Journey Today, I explored an interesting concept in Java — Shallow Copying 🧩 🔹 What I Learned: In Java, shallow copy is used when we want to create an exact duplicate of an object. It copies the object’s field values, but if the object contains references to other objects, those references are shared between the original and the copied object. ⚠️ Key Takeaway: The main disadvantage of shallow copying is that changes made to the copied object also reflect in the original object, since both share the same reference. 🔍 I also learned about the clone() method, which is commonly used to perform shallow copying in Java. I practiced this concept through a problem to understand how cloning works in real time. 💡 Simple Real-Life Example: Imagine three students joining the same institute for a Java Full Stack course. All three have the same course, same fees, and same institute location. Instead of writing separate details for each student, we can create one set of data (like course fees and place) for the first student and copy it for the other two — this is similar to using shallow copy. However, if one student later shifts to another branch and we update their institute location, the change also affects the original student’s data, since both share the same reference. 👉 To avoid this issue, we use Deep Copy, where a complete and independent copy of the object is made — and that’s what I’ll be learning tomorrow! 🎥 I’ve attached a short video/pictures demonstrating my code and output for better understanding. Every day is a step forward in mastering Java and Object-Oriented Programming! 💪 #JavaLearning #JavaProgramming #CoreJava #JavaDeveloper #CodingJourney #CodeNewbie #ProgrammersLife #LearnToCode #OOPsConcepts #CloningInJava #ShallowCopy #DeepCopy #TechLearning #SoftwareDevelopment #FullStackDeveloper #DeveloperJourney #StudentDeveloper #100DaysOfCode #DailyLearning #CodingCommunity #WomenInTech #TechEducation #CodeEveryday #DeveloperMindset #LearningNeverStops
To view or add a comment, sign in
-
🌟 Understanding the Difference Between extends and implements in Java In Java, both extends and implements are used for inheritance, but they serve different purposes depending on whether we are dealing with classes or interfaces. 🔹 extends Used when a class inherits another class, or an interface inherits another interface. Supports single inheritance. Helps in reusing existing code. 🔹 implements Used when a class implements an interface. The class must define all abstract methods declared in the interface. Supports multiple inheritance. implements 💡 Simple Tip: 👉 extends → inherits behavior 👉 implements → defines behavior Special thanks to my mentors Anand Kumar Buddarapu for their constant support and guidance in helping me understand core Java OOP concepts. Your mentorship means a lot! #Java #OOP #Programming #Extends #Implements #Learning #Mentorship #Thankful #Codegnan
To view or add a comment, sign in
-
-
As part of my Full Stack Java training at Codegnan IT Solutions, I recently explored how Local Variables and Static Blocks work in Java — and they’re quite interesting! 🔹 Local Variable A local variable is declared inside a method, constructor, or block. It is created when the method is called and destroyed once the method exits. 👉 Local variables must be initialized before use, and they cannot be accessed outside their scope. 🔹 Static Block A static block is used to initialize static data members. It runs only once, when the class is loaded into memory — even before the main() method executes. Every new concept in Java helps me understand how the language is both powerful and well-structured. Big thanks to Anand Kumar Buddarapu Sir for his detailed and practical explanations at Codegnan IT Solutions! 🙌 #Java #Codegnan #FullStackDeveloper #LearningJourney #Programming #JavaConcepts #OOPs
To view or add a comment, sign in
-
-
🏹 🔥 Day 47 of My Java Learning Journey 🎊 🚀 When to Use Which Java Collection? Real-World Guide for Every Developer ☕ Choosing the right Java Collection can make your code faster, cleaner, and easier to maintain just like choosing the right tool for the job 🔧 Here’s how I think about it 👇 👥 ArrayList -> When you need fast access and ordered elements. Example: Managing a list of users in an app where order matters. 🔁 LinkedList -> When you often add or remove elements from the middle. Example: Implementing a task queue for background jobs. 🎯 HashSet -> When you need unique elements without duplicates. Example: Storing unique email IDs or product SKUs. 🧩 HashMap -> When you want to store key-value pairs. Example: Mapping employee IDs to their details. 🌲 TreeMap / TreeSet -> When you need sorted order. Example: Keeping leaderboard scores in ascending order. 💡 When I first used a HashMap for user data, I couldn’t find why order kept changing 😅 that’s when I realized “Not all collections keep order — they keep efficiency!” 🎯 Every project teaches one thing Don’t just write code, understand your tools! 🔥 Save this post now and it’ll help you choose the perfect Java Collection next time you code! ☕💡 #Java #BackendDevelopment #JavaDeveloper #CollectionsFramework #CodingJourney #LearnInPublic #100DaysOfCode #ProgrammingLife #DeveloperCommunity #CodeNewbie #SoftwareEngineering #TechCareer #CodeWithYash #JavaLearning #ObjectOrientedProgramming #FullStackDeveloper #CodingMotivation #ProgrammingTips #LearningNeverStops #CareerGrowth 🌟
To view or add a comment, sign in
-
-
🥳 Day 33 of My Java Learning Journey 👌 Ever wondered why Java has both int and Integer? 🤔 That’s where Wrapper Classes step in they “wrap” primitive data types into objects, making them more powerful 💪 and flexible for real-world programming. 📦 For example: int - Integer char - Character boolean - Boolean Think of it like this 👇 A primitive is like a raw tool simple and fast. A wrapper class is like putting that tool in a smart box with extra buttons now you can do more with it, like store it in collections (ArrayList, HashMap) or use Java’s built-in methods! Last night, while working on ArrayList, I kept getting errors using int. Then I realized… I needed Integer, not int. That small “aha” moment taught me how wrapper classes bridge the gap between primitive and object-oriented worlds 🌍. Every small concept understood deeply is one step closer to becoming a confident backend developer. Keep learning, keep growing! 🌱 #Java #AccessModifiers #JavaLearning #CodingJourney #BackendDevelopment #JavaDeveloper #OOP #CodeSecurity #LearnInPublic #100DaysOfCode #TechCareer #ProgrammingTips #SoftwareEngineering #DevelopersJourney #CodeBetter #JavaProgramming #CleanCode #SpringBoot #BackendEngineer #Maang #Consistency #Motivation #Hustle #Google #CarrierGoal
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