🚀 Starting My Java Learning Journey – Day 13 ♦Topic: Exception Handling in Java Exception Handling is used to handle runtime errors so that the program does not crash abruptly. It helps in maintaining the normal flow of the program. ✅ Types of Exceptions 1)Checked Exceptions → Checked at compile time 2) Unchecked Exceptions → Occur at runtime ✅ Keywords Used in Exception Handling ✔ try → block where code is written ✔ catch → handles the exception ✔ finally → always executes (optional) ✔ throw → used to explicitly throw an exception ✔ throws → declares exceptions ✅ Example Program public class Main { public static void main(String[] args) { try { int result = 10 / 0; // may cause exception System.out.println(result); } catch (ArithmeticException e) { System.out.println("Cannot divide by zero"); } finally { System.out.println("Execution completed"); } } } Output: Cannot divide by zero Execution completed 💡 Key Points: ✔ Prevents program crash ✔ Helps handle runtime errors ✔ Improves program reliability #Java #JavaLearning #Programming #BackendDevelopment #CodingJourney #ExceptionHandling
Java Exception Handling Basics: Checked & Unchecked Exceptions
More Relevant Posts
-
🚀 Starting My Java Learning Journey – Day 14 🔹 Topic: Final Keyword & Static Keyword in Java In Java, final and static are important keywords used to control behavior of variables, methods, and classes. ✅ Final Keyword The final keyword is used to restrict modification. ✔ final variable → value cannot be changed ✔ final method → cannot be overridden ✔ final class → cannot be inherited ✅ Static Keyword The static keyword is used for memory management and sharing data. ✔ Belongs to the class, not objects. ✔ Shared among all objects. ✔ Can be accessed without creating an object. 💡 Key Points: ✔ final → restricts changes ✔ static → shared among all objects #Java #JavaLearning #Programming #BackendDevelopment #CodingJourney #JavaFinal #JavaStatic
To view or add a comment, sign in
-
🚀 Day 16 of My Java Learning Journey Today, I explored one of the most important OOP concepts in Java — Constructors 🔥 🔹 What I Learned: • Constructor is a special method used to initialize objects • It has the same name as the class • No return type (not even void) • Automatically called when object is created 🔹 Types of Constructors: • Default Constructor • Parameterized Constructor 💡 Key Insight: Java does not have a built-in copy constructor like C++, but we can create it manually if needed. 🧠 Realization: Constructors make object creation more structured and efficient — they are like the “starting point” of any object in Java. Consistency + Practice = Growth my mentor Aman Soni Vidhya Code Gurukul #Java #OOP #Programming #LearningJourney #CodeNewbie #100DaysOfCode #Developers #TechSkills
To view or add a comment, sign in
-
-
📘 Day 6 of Java Learning Series 🔹 Control Statements in Java (if-else, loops) Control statements help us control the flow of execution in a program. They allow decision-making and repetition of tasks. 🔸 1. if-else Statement (Decision Making) Used when we want to execute code based on a condition. 💡 Example: int age = 18; if (age >= 18) { System.out.println("You can vote"); } else { System.out.println("You cannot vote"); } 🔸 2. Loops (Repetition) Loops help us execute a block of code multiple times. 👉 for loop (when number of iterations is known) for (int i = 1; i <= 5; i++) { System.out.println(i); } 👉 while loop (runs while condition is true) int i = 1; while (i <= 5) { System.out.println(i); i++; } ✅ Key Takeaways: ✔ if-else → decision making ✔ loops → repetition ✔ for loop → fixed iterations ✔ while loop → condition-based execution 💬 Which loop do you use more – for or while? 👉 Follow me for more Java content 🚀 #Java #Programming #100DaysOfCode #Developers #Learning #CoreJava
To view or add a comment, sign in
-
-
Day 40 of Learning Java: Method Overloading Instead of creating different method names for similar tasks, we can use the same method name but change the parameters — and Java figures out which one to call. -So what exactly is Method Overloading? It’s when multiple methods in the same class have: ✔ Same name ✔ Different parameter list That’s it. Simple idea, but very powerful. -Ways to overload a method • Change the type of parameters • Change the number of parameters • Change the order of parameters Example- Think of a login system: Login using username + password Login using mobile + password Both are login actions, right? So instead of writing different method names, we just overload: login(String username, String password) login(long mobile, String password) Same method name → different ways to use it -Another relatable one Payment systems 👇 COD UPI Card Net Banking Instead of: paymentByUPI(), paymentByCard()… We can just do: payment() payment(String upi) payment(long card) payment(String user, String pass) - Important things I learned • Just changing return type won’t work (it gives error) • Overloading happens at compile time • Works with static, private, and even final methods • Yes, even main() can be overloaded (but JVM only runs the standard one) #Java #LearningInPublic #100DaysOfCode #Programming #OOP #CodingJourney
To view or add a comment, sign in
-
-
🚀 Core Java Learning Journey Explored Constructors in Java and the rules for writing them ☕ 🔹 What is a Constructor? A constructor is a special method used to initialize objects. It is automatically called when an object is created. 📌 Key Features of Constructors: ✅ Same name as the class ✅ No return type (not even "void") ✅ Automatically invoked during object creation ✅ Used to initialize instance variables 🔹 Types of Constructors: ✔️ Default Constructor ✔️ Parameterized Constructor 📌 Rules for Writing Constructors: 🔸 Constructor name must be the same as the class name 🔸 It should not have any return type 🔸 Can be overloaded (multiple constructors in one class) 🔸 Cannot be static, final, or abstract 🔸 If no constructor is written, Java provides a default constructor 💡 Example: class Student { int id; String name; Student(int i, String n) { // Parameterized constructor id = i; name = n; } } 🎯 Key Takeaway: Constructors make object initialization easy and are a fundamental part of Object-Oriented Programming in Java. Learning and growing at Dhee Coding Lab 💻 #Java #CoreJava #Constructors #OOP #Programming #LearningJourney #FullStackDevelopment
To view or add a comment, sign in
-
🚀 Starting My Java Learning Journey – Day 16 🔹 Topic: Encapsulation in Java. Encapsulation is one of the core OOP concepts. It is the process of wrapping data (variables) and code (methods) into a single unit (class). It also helps in data hiding. 📌 How to Achieve Encapsulation? ✔ Declare variables as private. ✔ Provide public getter and setter methods to access and update values. 📌 Example Program class Student { private String name; // Getter method public String getName() { return name; } // Setter method public void setName(String name) { this.name = name; } } public class Main { public static void main(String[] args) { Student s1 = new Student(); s1.setName("John"); System.out.println(s1.getName()); } } Output: John 💡 Key Points: ✔ Protects data from unauthorized access. ✔ Improves security and flexibility. ✔ Achieved using private variables + getters/setters. #Java#JavaLearning #Programming #BackendDevelopment #CodingJourney #Encapsulation #OOP#
To view or add a comment, sign in
-
✨ I’m happy to share that today I learned the core concepts of Object-Oriented Programming (OOPs) in Java by implementing 🚀OOPs Pillars Explained in a Single Program practical way by implementing all concepts in a single Java program. 📌 OOPs Pillars: 🔹 Encapsulation Binding data (variables) and methods into a single unit (class) and restricting direct access using access modifiers. 🔹 Inheritance Acquiring properties and behaviors from one class to another using the “extends” keyword. Helps in code reusability. 🔹 Polymorphism One method, multiple behaviors. Achieved using method overloading and method overriding. 🔹 Abstraction Hiding implementation details and showing only essential features using abstract classes and interfaces. 📌 Key Understanding: Instead of learning concepts individually, implementing all OOPs pillars in one program gives a clear picture of how they work together in real-world applications. 💡 This is the core foundation of Java and essential for building scalable applications. #CoreJava #OOPsConcepts #JavaLearning #Programming #TapAcademy #LearningJourney #DeveloperSkills
To view or add a comment, sign in
-
-
🚀 Day 32/100 – Java Learning Journey Today’s focus was on a very important yet often overlooked concept in Java: Wrapper Classes & Cache Memory. 🔍 Key Learnings: ✔️ Wrapper Classes & Object Creation Wrapper classes like Integer, Character, etc., allow us to convert primitive data types into objects, enabling their use in collections and advanced operations. ✔️ Cache Memory in Wrapper Classes Java optimizes memory usage using cache memory for certain values. For example, Integer values between -128 to 127 are cached. 👉 Instead of creating new objects repeatedly, Java reuses existing ones — improving performance. ✔️ Important Insight When using Integer.valueOf(), Java may return a cached object. But using new Integer() always creates a new object (less efficient). ✔️ Special Case – Decimal Types Types like Float and Double do not use cache memory, which is an important distinction for optimization. 💡 Hands-on Example: Converted a string "10" into an integer using: Integer i = Integer.valueOf(s); 📌 Takeaway: Understanding internal optimizations like caching helps write efficient and memory-optimized Java code, which is crucial for real-world applications and interviews. 🔥 Consistency is key — learning something new every single day! #Java #100DaysOfCode #LearningJourney #Programming #JavaDeveloper #Coding #SoftwareDevelopment #BackendDevelopment #TechGrowth Meghana M 10000 Coders
To view or add a comment, sign in
-
📘✨ Collections and Framework Introduction to ArrayList in Java – Conceptual Overview 🚀 Continuing my learning, I focused on the theory behind ArrayList, a fundamental part of Java’s data handling 📋 🔹 ArrayList is a class that implements a dynamic array, meaning its size can change automatically during runtime 🔄 🔹 It belongs to the Java Collections Framework and is widely used for storing and managing data efficiently 💡 Core Properties: ✔ Preserves insertion order 📑 ✔ Allows duplicate elements 🔁 ✔ Provides random (index-based) access ⚡ ✔ Dynamically resizes as data grows 📈 💡 Performance Insight ⚙️ - Fast for accessing elements (O(1)) - Slower for inserting/removing elements in between (due to shifting) - Better suited for read-heavy operations 💡 Behind the Scenes 🔍 - Internally uses an array structure - When capacity is full, it creates a larger array and copies elements - Default capacity grows automatically 💡 Use Cases 🌍 📌 Managing lists of students, products, or records 📌 Applications where order matters 📌 Situations where frequent searching/access is required 💡 Drawbacks ⚠️ ❌ Not efficient for frequent insertions/deletions ❌ Not thread-safe without synchronization 🎯 Final Thought 💡 ArrayList offers a perfect balance between simplicity and performance, making it one of the most commonly used data structures in Java 💻✨ #Java #ArrayList #Collections #Programming #CodingLife #Developer #LearningJourney #HarshitT #TapAcademy
To view or add a comment, sign in
-
-
Day 38 at #TapAcademy 🚀 ArrayList in Java – A Must-Know for Every Developer When working with Java, one of the most commonly used data structures is ArrayList — a powerful and flexible part of the Java Collection Framework. 🔹 What is ArrayList? ArrayList is a resizable array implementation of the List interface. Unlike traditional arrays, it can grow or shrink dynamically as elements are added or removed. 🔹 Why use ArrayList? ✔ Dynamic size (no need to define length in advance) ✔ Allows duplicate elements ✔ Maintains insertion order ✔ Provides fast access using index ✔ Comes with rich built-in methods 🔹 Common Methods: 📌 add(E e) – Add element 📌 get(int index) – Access element 📌 set(int index, E e) – Update element 📌 remove(int index) – Delete element 📌 size() – Get number of elements 🔹 Constructors: 📌 ArrayList() – Creates an empty list 📌 ArrayList(int initialCapacity) – Sets initial size 📌 ArrayList(Collection<? extends E> c) – Creates list from another collection 💡 Example: ArrayList<String> names = new ArrayList<>(); names.add("Alice"); names.add("Bob"); names.add("Charlie"); System.out.println(names); 🔹 Difference: Arrays vs ArrayList 📌 Arrays ▪ Fixed size (cannot grow/shrink) ▪ Can store primitives (int, char, etc.) ▪ No built-in methods (limited operations) ▪ Faster for basic operations 📌 ArrayList ▪ Dynamic size (resizable) ▪ Stores only objects (wrapper classes like Integer) ▪ Rich built-in methods (add, remove, etc.) ▪ More flexible and easy to use 📈 Understanding ArrayList is essential for writing efficient, clean, and scalable Java programs—whether you're preparing for interviews or building real-world applications. #Java #ArrayList #Programming #Coding #DataStructures #JavaDeveloper #Learning #Tech #TapAcademy
To view or add a comment, sign in
-
Explore related topics
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