Java Method Types and For Loop Basics

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

  • diagram

Great breakdown! Methods and loops are the bread and butter of programming. Understanding the difference between void and return types early on makes debugging so much easier later. Keep it up!

Like
Reply

To view or add a comment, sign in

Explore content categories