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
Understanding the public static void main() method in Java
More Relevant Posts
-
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
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
-
💡 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 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
-
🌟 Day 55/180 – Java Full Stack Development 🌟 📘 Topic: Why Multiple Inheritance is Not Possible in Java 🔹 1️⃣ What I Learned Today: I learned that multiple inheritance is not possible in Java using classes because it causes a problem called the Diamond Problem. 🔹 2️⃣ What is Multiple Inheritance? It means a child class inherits from two parent classes at the same time. Example: class A {} class B {} class C extends A, B {} // ❌ Not allowed in Java 🔹 3️⃣ The Diamond Problem (The Real Reason): Imagine this situation 👇 Class A has a method show(). Classes B and C both extend A and override show(). Now Class D tries to extend both B and C. When we call show() from D, Java gets confused — 👉 “Should I call show() from B or from C?” This ambiguity is called the Diamond Problem 💎 🔹 4️⃣ Why Java Avoids It: To keep the language simple, clear, and unambiguous, Java designers disallowed multiple inheritance using classes. 🔹 5️⃣ Then How to Achieve It? ✅ Using Interfaces! Interfaces only have method declarations (no implementation), so even if multiple interfaces have the same method, the child class defines its own version — no confusion! 😎 Example: interface A { void show(); } interface B { void show(); } class C implements A, B { public void show() { System.out.println("Hello from C!"); } } 💡 Key Takeaways: Multiple inheritance ❌ not possible using classes. Diamond Problem 💎 causes ambiguity. Interfaces ✅ solve the problem. Java keeps it clean, simple, and safe. #Day55Of180 #JavaFullStack #JavaLearning #OOPsConcepts #InheritanceInJava #DiamondProblem #JavaProgrammer #LearnJava #JavaDeveloper #JavaCode #CodingJourney #FullStackDeveloper #CodeNewbie #ProgrammersLife #100DaysOfCode #TechLearning #DeveloperCommunity #WomenInTech #CodingMotivation #SoftwareEngineer #CodeDaily #BackendDeveloper #ProgrammingLife #CodeWithMe #LearnToCode #CodingIsFun #TechJourney #StudyWithMe #ITCareer #JavaConcepts
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
-
🌈 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
-
-
Types of Inheritance in Java 💻 Java Full Stack Journey with Codegnan 👨🏫 Guided by our mentor Anand Kumar Buddarapu Sir. 👉 What is Inheritance? Inheritance is one of the core pillars of Object-Oriented Programming (OOP). It allows one class (child class) to acquire the properties and behaviors of another class (parent class) using the extends keyword. This promotes code reusability, method overriding, and hierarchical relationships among classes. ✨ Types of Inheritance in Java: 1️⃣ Single Inheritance ➡️ One subclass inherits from one superclass. 📘 Example: class B extends A 2️⃣ Multilevel Inheritance ➡️ A class inherits from another derived class (chain of inheritance). 📘 Example: class C extends B extends A 3️⃣ Hierarchical Inheritance ➡️ Multiple classes inherit from a single parent class. 📘 Example: class B extends A, class C extends A 4️⃣ Multiple Inheritance (Through Interfaces) ➡️ A class implements multiple interfaces to achieve multiple inheritance behavior. 📘 Example: class A implements X, Y 5️⃣ Hybrid Inheritance ➡️ A combination of different types of inheritance (possible through interfaces) 🧠 Key Takeaway: Inheritance simplifies code structure by promoting reusability, scalability, and flexibility. It forms the base for concepts like polymorphism, method overriding, and upcasting/downcasting, making Java truly object-oriented. 🙏 Thanks to our mentor Anand Kumar Buddarapu Sir for your valuable guidance and support. Thanks to Saketh Kallepu Sir, Uppugundla Sairam Sir, and the entire Codegnan Team for their continuous motivation and encouragement.
To view or add a comment, sign in
-
-
🤯 Day 32 of My Java Learning Journey 🏹 💡 Ever wondered why your Java code runs slow when you keep joining strings in a loop? That’s where StringBuilder becomes your superhero! In Java, String and StringBuilder may look similar but behave very differently. A String is immutable once created, it can’t be changed. So every time you modify it, a new object is created in memory. 😬 On the other hand, StringBuilder is mutable meaning it changes the existing value without creating a new one! That’s why it’s perfect for tasks like concatenating text in loops or building dynamic messages. 🧩 Last week, I tried concatenating 1000 names using String… my program lagged 😅. Switched to StringBuilder, and boom it finished instantly! Lesson learned: choose performance wisely! 💪 Keep learning, keep optimizing small code changes can make a big difference in your growth as a developer! #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
-
-
Java How-Tos: Level Up Your Coding Game with Practical Guides Java How-Tos: Stop Googling and Start Coding Like a Pro Alright, let's be real. Learning Java is one thing; actually using it in the wild is a whole different ball game. You've got the basics down—variables, loops, classes—but then you sit down to build something and suddenly you're spending half your day on Stack Overflow, trying to remember the exact syntax for reading a file or how to sort that stupid ArrayList. We've all been there. It's like knowing all the words in the dictionary but struggling to write a compelling novel. That's where this guide comes in. Think of this as your personal Java cheat sheet for the most common, "how do I do that again?" tasks. We're going to cut through the fluff and give you the practical, copy-paste-friendly, and understandable how-tos that you'll use in almost every project. Let's dive in. How to Convert a String to an Integer (and Vice Versa) This is probably one of the first roadblocks every new Java dev hits. You get user input from the conso https://lnkd.in/gBFq_ivp
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