🚀 Daily Learning Update – Day 6 🚀 🧠 Java Practice: Methods (Functions) 🔹 What is a Method? A block of code that performs a specific task May or may not return a value Must be part of a class Improves code reusability 🔹 Method Syntax access_modifier return_type method_name(parameters) 🔹 Parameters Formal Parameters → defined in method Actual Parameters → passed during method call 🔹 Types of Methods 1️⃣ Predefined Methods Built-in methods from Java libraries Directly usable (e.g., Math, System) 2️⃣ User-Defined Methods Created by programmers for custom logic Uses stack frame for execution Stack frame is removed after execution 🔹 Parameter Passing in Java Primitives → Pass by Value Objects → Reference copy (points to same memory) 🔹 Method Overloading Same method name Different number or type of parameters 🔹 Instance (Non-Static) Methods Accessor (Getter) → reads data Mutator (Setter) → modifies data 📌 Key Takeaway: Clean method design = reusable, readable, and maintainable code. #Java #DSA #Programming #LearningEveryDay #SoftwareDevelopment #CodeReusability
Java Methods Explained: Functions, Syntax, and Best Practices
More Relevant Posts
-
🚀 Day 16 of Core Java Learning – Non-Static Methods & Object Creation Today, I focused on strengthening my understanding of non-static (instance) methods and objects in Java by implementing a real-world Employee class example. 📘 What I Learned & Practiced: Creating objects using the new keyword Understanding how non-static methods belong to objects, not the class How each object maintains its own instance data Accessing instance variables through objects Calling one non-static method from another Modeling real-world scenarios using classes and objects 🔍 Key Insight: Static vs Non-Static Methods Static Methods: Belong to the class Can be called without creating an object Access only static data directly Same behavior across all objects Non-Static Methods: Belong to individual objects (instances) Require object creation to be called Can access both instance and static data Behavior depends on object-specific data This hands-on practice helped me clearly understand how object-oriented principles work in real applications, especially how data and behavior are tied to individual objects. Excited to continue building a strong foundation in Java! 💻🔥 #Java #CoreJava #ObjectOrientedProgramming #LearningJourney #JavaDeveloper #ProgrammingBasics #100DaysOfCode Meghana M
To view or add a comment, sign in
-
Finished working through the Java basics today. If I’m honest, most of these topics looked simple at first, but writing and running code showed me how easy it is to assume things and be wrong. What these basics actually taught me: - data types decide behavior, not just storage - integer vs decimal operations matter more than expected - Java is strict by design — casting, booleans, execution order - small expressions can change results in non-obvious ways - understanding why something happens is more important than getting output once. - Earlier, I thought learning basics was just a formality before “real coding”. Now I see that most bugs start right here. Still at the beginning, but trying to build the habit of understanding fundamentals properly instead of rushing ahead. Continuing the journey. #Java #LearningInPublic #Beginner #DSA
To view or add a comment, sign in
-
Java Fundamentals I Revisited Today (Zero → Depth) Sometimes revisiting basics teaches more than learning something new. Today I went deeper into two concepts we use often, but don’t always fully think through. 🔹 Method Reference (::) At the simplest level, a method reference is a way to pass behavior, not execute it. list.forEach(System.out::println); What this really means: The method is not called immediately Java only keeps a reference to it It gets executed later via a functional interface Internally handled using invokedynamic (same as lambdas) I see it now as: “If logic already exists, don’t rewrite it — reuse it clearly.” 🔸 Method Hiding Method hiding happens when a static method in a child class has the same signature as one in the parent. Key realization: Static methods belong to the class, not the object Resolution happens at compile time The reference type decides which method is called This is not polymorphism Understanding this removes a lot of confusion around static methods in inheritance. 🧠 What this reinforced for me Clean code starts with clear mental models Method references improve expressiveness Static methods are meant for utility, not behavior variation Knowing how the JVM resolves things changes how you design ✨ Small concepts. Deep impact. Still learning. Still refining fundamentals. Stay curious. Stay learning. 🚀 #Java #LearningJourney #MethodReference #JVM #CleanCode #SoftwareEngineering
To view or add a comment, sign in
-
Post 4 - Sharing a learning from Effective Java Item 4: Enforce Noninstantiability with a Private Constructor Some classes are not meant to be instantiated (e.g. utility classes). But Java adds a public constructor by default if you don’t define one. ❌ Problematic utility class: public class MathUtils { public static int add(int a, int b) { return a + b; } } This allows: new MathUtils(); // unwanted ✅ Correct approach: public class MathUtils { private MathUtils() { throw new AssertionError("No instances allowed"); } public static int add(int a, int b) { return a + b; } } Why this matters: • Prevents accidental instantiation • Makes intent explicit • Improves API design clarity Key takeaway: If a class is not meant to be instantiated, make it impossible to do so. 📖 Effective Java — Joshua Bloch #Java #EffectiveJava #CleanCode #BackendEngineering #SoftwareEngineering #DesignPrinciples #JavaTips #ProductEngineering
To view or add a comment, sign in
-
Day 10.... 💡 Today I Learned: Method Types & For Loop in Java 👨💻 In today’s programming class, I learned about two important method types in Java: 1️⃣ Method with Parameters and No Return Type 👉 This type of method takes input values (parameters) but does not return any value. It simply performs an operation and displays the result. 2️⃣ Method with Parameters and Return Type 👉 This type of method accepts parameters and returns a value of a specific data type. If the return type is `int`, the method returns an integer. If it is `float`, it returns a float, and so on. 🔁 The parameters and return types can also follow typecasting rules: Implicit Typecasting:Done automatically by Java (smaller → larger type) Explicit Typecasting:Done manually by the programmer (larger → smaller type) 🔄 Also Learned: For Loop in Java A for loop is used to repeat a block of code multiple times. It has four main parts: Initialization – Setting the starting point Condition – Checking whether to continue Updation– Increment or decrement Body – The code that executes repeatedly 🧠 The loop runs until the condition becomes false, then exits and moves to the next part of the program. 📚 I also practiced a few problems on methods and for loops, which helped me understand how Java handles operations step by step. 🚀 Learning by doing really makes programming more fun and meaningful! #Java #LearningJourney #ProgrammingBasics #ForLoop #MethodsInJava #CodingLife
To view or add a comment, sign in
-
-
The most ignored line in Java (but the most important one) 👉 Every Java program you’ve ever written starts with this line… but most beginners don’t really understand it: 𝗽𝘂𝗯𝗹𝗶𝗰 𝘀𝘁𝗮𝘁𝗶𝗰 𝘃𝗼𝗶𝗱 𝗺𝗮𝗶𝗻(𝗦𝘁𝗿𝗶𝗻𝗴[] 𝗮𝗿𝗴𝘀) When I was learning Java, I used to write this line from memory. No understanding. Just copy-paste. Until I realized: 👉 This one line decides 𝙝𝙤𝙬 𝙮𝙤𝙪𝙧 𝙚𝙣𝙩𝙞𝙧𝙚 𝙅𝙖𝙫𝙖 𝙥𝙧𝙤𝙜𝙧𝙖𝙢 𝙨𝙩𝙖𝙧𝙩𝙨. Let’s break it simply: 🔹𝙥𝙪𝙗𝙡𝙞𝙘 → Java can access this method from anywhere 🔹 𝙨𝙩𝙖𝙩𝙞𝙘 → No object needed. JVM can call it directly 🔹 𝙫𝙤𝙞𝙙 → It returns nothing 🔹 main → This is the starting point of your program 🔹 𝙎𝙩𝙧𝙞𝙣𝙜[] 𝙖𝙧𝙜𝙨 → Used to take input from the command line In short: This is the 𝗴𝗮𝘁𝗲 through which Java enters your program. Once you truly understand this line, ✔ errors make more sense ✔ execution flow becomes clearer ✔ backend concepts become easier later If you are serious about Java, don’t just memorize — 𝘂𝗻𝗱𝗲𝗿𝘀𝘁𝗮𝗻𝗱. This is Post #1 of my 𝗝𝗮𝘃𝗮 𝗳𝗼𝗿 𝗕𝗲𝗴𝗶𝗻𝗻𝗲𝗿𝘀 𝘀𝗲𝗿𝗶𝗲𝘀. I’ll keep sharing simple, practical Java concepts regularly. 💬 𝗜𝗳 𝘆𝗼𝘂’𝗿𝗲 𝗹𝗲𝗮𝗿𝗻𝗶𝗻𝗴 𝗝𝗮𝘃𝗮, 𝗰𝗼𝗺𝗺𝗲𝗻𝘁 “𝗝𝗔𝗩𝗔” 𝗮𝗻𝗱 𝘁𝗲𝗹𝗹 𝗺𝗲 𝘆𝗼𝘂𝗿 𝗹𝗲𝘃𝗲𝗹 (𝘀𝗰𝗵𝗼𝗼𝗹 / 𝗰𝗼𝗹𝗹𝗲𝗴𝗲 / 𝗯𝗲𝗴𝗶𝗻𝗻𝗲𝗿 / 𝘄𝗼𝗿𝗸𝗶𝗻𝗴 𝗽𝗿𝗼𝗳𝗲𝘀𝘀𝗶𝗼𝗻𝗮𝗹). #Java #JavaBeginners #LearnJava #Programming #ComputerScience #CodingLife #Students #SoftwareEngineering #BackendDevelopment
To view or add a comment, sign in
-
-
🧑💻🔥 “Small commits today, powerful results tomorrow.” 🔥🧑💻 Learning isn’t about perfection—it’s about showing up and improving a little every day 💪📈 🌱✨ Day 4 of My Daily Java Learning Journey ✨🌱 (Missed posting yesterday, but stayed consistent with learning—and that’s what truly matters 🔥) 📘 Today’s Focus: Arrays & Strings in Java 🧠💻 🔹 Arrays in Java 📊 Efficiently storing and accessing multiple values using a single variable 🔹 Concept of String in Java 🧵 Understanding immutability and how Java handles strings in memory 🔹 String Comparison & Concatenation 🔍➕ Learning the right way to compare strings (== vs .equals()) and combine them effectively 🔹 StringBuffer Class 🛠️ Thread-safe and mutable strings for synchronized environments 🔹 StringBuilder Class ⚡ High-performance string manipulation when thread safety isn’t required 💡 Why this matters: ✨ Strong Java fundamentals ✨ Better performance & memory usage ✨ Cleaner, more efficient code 📌 Reminder to myself: 🔥 Consistency beats motivation 📅 Missing a post doesn’t mean missing progress 🚀 Every small effort compounds over time Continuing my journey— One day. One concept. One step closer to mastery. 💻✨ Happy learning 😊🥳 #Java #JavaLearning #JavaDeveloper #LearnJava #Programming #CodingJourney #QALife #DailyLearning #Consistency #TechSkills #OOP #CodingMotivation
To view or add a comment, sign in
-
🚀🔥 Day 12 of My Content Journey | Real-Time Java Use Case 🔥🚀 Today I worked on a real-world scenario that is widely used in libraries, colleges, and online learning platforms. 💡 Real-Time Use Case Library Book Issue & Return System (Basic Logic) Before issuing a book, systems check: Book availability Number of books already issued Allowed issue limit This Java program demonstrates the core logic behind book issue and return handling. 🎯 Why This Is Real-Time? ✔ Used in library management systems ✔ Demonstrates inventory & validation logic ✔ Common backend logic example I’m focusing on small, real-time Java programs to understand how real systems work behind the scenes. 📌 One day, one practical example 📌 Learning by building 📌 Staying consistent If you’re learning Java, follow along 💻✨ Feedback and suggestions are welcome 🙌 #Java #RealTimeApplication #LibraryManagement #CodingJourney #LearningInPublic #BackendLogic #JavaDeveloper #Consistency
To view or add a comment, sign in
-
-
🚀 Core Java Learning – Understanding main() Method & Program Execution Today, I strengthened my understanding of one of the most important concepts in Core Java – the main() method and execution flow. 🔹 Learned how the Operating System (OS) interacts with a Java program 🔹 Understood why the main() method is mandatory for program execution 🔹 Explored how the OS transfers control of execution to the JVM through main() 🔹 Gained clarity on why public, static, and void keywords are used in the main() method 🔹 Compared execution flow concepts with C language for better conceptual understanding 📌 Key takeaway: Without the main() method, the OS cannot start executing a Java program. It acts as the entry point that bridges the OS and the Java application. This session helped me build a strong foundation in Core Java, which is essential for advanced concepts ahead like OOP, JVM internals, and application development. ✨ Learning step by step and enjoying the process! #CoreJava #JavaBasics #MainMethod #ProgrammingFundamentals #LearningJourney #StudentDeveloper
To view or add a comment, sign in
-
-
Day 8 – Java | Pass by Value & Object Reference Behavior 🚀 Today’s learning at Tap Academy focused on how Java passes data to methods and how memory plays a key role in this behavior. I learned that Java always follows pass by value, but the outcome differs based on what is passed: For primitive data types, a copy of the value is passed, so changes inside a method do not affect the original variable. For objects, a copy of the reference is passed. Multiple references can point to the same object in heap memory, so changes made using one reference are reflected through others. Key takeaways: Difference between changing an object’s state vs changing the reference How stack and heap memory work together during method calls Why object data changes but primitive values don’t This session clarified one of the most commonly misunderstood concepts in Java and strengthened my understanding of memory management and OOP fundamentals. #Java #OOPS #PassByValue #ObjectReference #HeapMemory #StackMemory #TapAcademy #LearningJourney #Day8
To view or add a comment, sign in
-
Explore related topics
- Writing Readable Code That Others Can Follow
- Clear Coding Practices for Mature Software Development
- How to Improve Code Maintainability and Avoid Spaghetti Code
- Coding Best Practices to Reduce Developer Mistakes
- How to Write Maintainable and Readable Tests
- Advanced Techniques for Writing Maintainable Code
- How to Write Maintainable, Shareable Code
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