Day 33 of Learning Java Today I learned about Return Types in Java methods, and it finally started to make sense how methods give results back! Here’s what I understood: 🔹 Every method has a return type 🔹 It tells what kind of value the method will give back 🔹 There are mainly two types: Primitive Data Types (PDT) : • byte • short • int • long • char • String • float • double • boolean Reference Data Types (RDT) : • Arrays • Classes • Interfaces • Annotations • Enums 🔹 A method can also return an object 🔹 The "return" keyword is used to send the value back 🔹 If nothing is returned, we use "void" Thanks to my mentor Ashim Prem Mahto for the clear explanations and for always clearing my doubts. #Java #LearningJava #ProgrammingJourney #CodingLife #JavaBasics #SoftwareDevelopment #DeveloperJourney #TechLearning #StudentLife
Return Types in Java Methods Explained
More Relevant Posts
-
📘 Day 43 of My Learning Journey Today, I learned about the equals() method from the java.lang package in Java. 🔹 The equals() method is used to compare two objects for equality. 🔹 By default, it checks whether both objects refer to the same memory location. 💡 But the real power comes when we override equals() to compare object values instead of references. 👉 Example: Two objects with the same data (like two students with the same ID) can be treated as equal using equals(). 🔸 This concept is very important when working with collections like lists, sets, and maps. 🚀 Understanding equals() helps in writing accurate comparisons and avoiding logical errors in Java programs. Step by step, improving my Java skills and writing better code! 💻 #Java #LearningJourney #Day43 #OOP #Programming #TechSkills
To view or add a comment, sign in
-
-
🚀 Day 39/45 – Learning File Handling in Java 📂 Today I explored File Handling in Java, which allows us to store and manage data permanently using files. 📚 What I Learned: ✔ Creating files using File class ✔ Writing data using FileWriter ✔ Reading files using FileReader ✔ Efficient reading using BufferedReader ✔ Deleting files in Java 💻 Practice Work: • Created and managed text files • Performed read/write operations • Practiced real-world file-based scenarios 🎯 Key Takeaway: File Handling is essential for building real-world applications where data persistence is required. #Java #FileHandling #Programming #CodingJourney #LearningInPublic #BackendDevelopment
To view or add a comment, sign in
-
🚀 Day 48 of My Java Learning Journey Today, I explored one of the most important concepts in Java – Collection Framework 💡 📌 What I Learned: Collection Framework is a set of classes and interfaces used to store and manipulate data efficiently It was introduced in JDK 1.2 by Josh Bloch Acts as an alternative to Data Structures in Java 📊 Key Components: Interfaces → List, Set, Queue, Map Classes → ArrayList, LinkedList, HashSet, HashMap 🔥 Why Collections? ✔ Dynamic size (no fixed length like arrays) ✔ Inbuilt methods (add, remove, etc.) ✔ Efficient data handling ✔ Reduces coding effort 💻 Key Features: Allows heterogeneous data Maintains insertion order (List) Allows duplicates (List) Improves performance in real-world applications 📈 Takeaway: Collection Framework is a must-know concept for interviews and real-time development. Almost every Java application uses it! #Day48 #Java #CollectionsFramework #JavaDeveloper #LearningJourney #Coding #Programming
To view or add a comment, sign in
-
-
📅 Day 45 of My Learning Journey Today, I explored two important concepts in Java: String Class and StringBuffer. 🔹 String Class Strings are immutable, meaning once an object is created, it cannot be changed. Any modification results in the creation of a new object. Widely used for safe and secure data handling. 🔹 StringBuffer StringBuffer is mutable, meaning it allows changes without creating new objects. It is thread-safe (synchronized), making it suitable for multi-threaded environments. Provides methods like append(), insert(), and reverse() for efficient string manipulation. 💡 Key Takeaway: Use String when data should remain constant, and StringBuffer when frequent modifications are required, especially in multi-threaded applications. 📌 Understanding the difference between immutability and mutability helps in writing optimized and efficient Java programs! #Day45 #Java #StringClass #StringBuffer #Programming #LearningJourney #TechSkills
To view or add a comment, sign in
-
-
🔥 Today's Learning Update — #Day51 Today’s concept: Why are Strings immutable in Java? 💡 What I understood In Java, once a String is created, it cannot be changed. If we try to modify it, a new String object is created instead. 💡 Why is it designed this way? 1️⃣ String Pool (Memory Efficiency) Multiple variables can point to the same String value without creating new objects. Since Strings are immutable, this is safe and saves memory. 2️⃣ Security Strings are used in things like file paths and database connections. If they were mutable, they could be changed during execution, which could cause serious issues. 3️⃣ HashCode Performance Since a String never changes, its hashCode can be cached. This makes it very efficient when used in structures like HashMap. 💡 Important observation When we “modify” a String, we are actually creating a new object, not changing the existing one. If we need frequent modifications, it’s better to use StringBuilder, which is mutable. 🧠 What I learned today Some design decisions in Java are not limitations — they are optimizations for performance, safety, and memory efficiency. #Java #CoreJava #String #Programming #SoftwareEngineering #ConsistencyCurve
To view or add a comment, sign in
-
-
🔥 Title Solved "Library Fine" Problem Using Java 📚💻 📄 Description I recently worked on the Library Fine problem, a great exercise to strengthen conditional logic and real-world problem-solving. 🔍 Problem Summary: Calculate the fine for returning a library book late based on: Days late Months late Years late 💡 Approach: Compare return date with due date Apply fine rules based on hierarchy (year → month → day) Ensure minimum penalty logic is followed ✨ Key Learning: Breaking down conditions step-by-step helps avoid logical errors and improves clarity in coding. ⚡ Implemented in Java with simple and efficient conditional checks. 🏷️ Tags #Java #DSA #Coding #ProblemSolving #HackerRank
To view or add a comment, sign in
-
-
Exploring one of the most powerful concepts in Java — Polymorphism, and I achieved it using Inheritance with a simple Plane program. In Java, polymorphism allows a single object to take multiple forms. Using inheritance and method overriding, I implemented a Plane example where different types of planes (like Cargo Plane and Passenger Plane) show different behaviors even though they share a common parent class. It was really interesting to see how a parent class reference can call different implementations at runtime — making the program dynamic and flexible. A big thank you to TAP Academy for teaching this concept so clearly and effortlessly. The real-time examples, like the Plane program, made it much easier to understand how inheritance and polymorphism work together. Excited to apply these concepts in real-world projects and keep growing 🚀 #Java #OOP #Polymorphism #Inheritance #CodingJourney #Learning #SoftwareDevelopment #TAPAcademy
To view or add a comment, sign in
-
🚀 Solved: Java Priority Queue Challenge (HackerRank) Today I worked on an interesting problem involving PriorityQueue in Java, where students are served based on multiple priority conditions: 🎯 Priority Rules: ✔ Highest CGPA first ✔ If CGPA is same → Name in ascending order ✔ If both same → Lower ID first 💡 What I learned: 🔹 How to use Comparator with PriorityQueue 🔹 Handling multiple sorting conditions 🔹 Difference between writing code in Eclipse vs HackerRank 🔹 Importance of using the correct constructor: PriorityQueue<Student> pq = new PriorityQueue<>(1, new Comparator<Student>() { public int compare(Student s1, Student s2) { if (s1.getCGPA() != s2.getCGPA()) { return Double.compare(s2.getCGPA(), s1.getCGPA()); } else if (!s1.getName().equals(s2.getName())) { return s1.getName().compareTo(s2.getName()); } else { return s1.getID() - s2.getID(); } } }); ⚠️ Key Debugging Insight: I initially faced an error: 👉 “no suitable constructor found for PriorityQueue” ✔ The fix was to provide initial capacity along with Comparator, especially in platforms like HackerRank. 📌 Takeaway: PriorityQueue is powerful, but understanding custom ordering logic and environment differences is crucial. #Java #DataStructures #PriorityQueue #HackerRank #ProblemSolving #JavaDeveloper #CodingJourney #Learning
To view or add a comment, sign in
-
Day 12 of Learning Java Today I learned something small in Java that actually plays a big role in programming — Type Casting. At first, I thought it was complicated. But the idea is actually simple. Sometimes in programming, we need to convert one data type into another. For example, converting an `int` into a `double`. That process is called Type Casting. Java mainly has two types of type casting: - Implicit Casting (Widening) This happens automatically when converting a smaller data type into a larger one. Example: `int → double` - Explicit Casting (Narrowing) This is done manually when converting a larger type into a smaller one. Example: `double → int` Simple example: int num = 10; double result = num; // implicit casting double price = 19.99; int rounded = (int) price; // explicit casting What I’m realizing while learning Java is that even small concepts build the foundation of programming logic. Slowly learning. Step by step. #JavaLearning #LearningInPublic #CodingJourney #JavaProgramming #WomenInTech
To view or add a comment, sign in
-
🚀 Day 57 of My Java DSA Journey Today I worked on a classic Dynamic Programming problem: 💡 Subset Sum Problem 🧠 Approach: • Used recursion with memoization • At each step, decided whether to include or exclude an element • Stored intermediate results to optimize performance 🔍 Key Insight: A subset with sum k exists if: We can form k without current element OR We can form k - arr[i] including current element ⚡ What I learned: • DP pattern similar to Knapsack • Importance of proper memoization • Handling boolean DP states 🔥 Complexity: • Time: O(n × k) • Space: O(n × k) 🎯 Takeaway: Many DP problems are variations of a few core patterns. #Day57 #90DaysOfCoding #DSA #DynamicProgramming #Java
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