Home / Programs / Method in java, Passing Parameters by Value
🚀 Programming Example

Method in java, Passing Parameters by Value

👁 2,731 Views
💻 Practical Program
📘 Step Learning
Learn this program step-by-step with algorithm, source code, output and detailed explanation.

💻 Program Code

 public class ExampleVoidMethod {

   public static void main(String[] args) {
      methodmarks(92.7);
   }

// The void keyword allows us to create methods which do not return a value.

   public static void methodmarks(double marks) {
      if (marks <= 100) {
         System.out.println("Rank:outstanding");
      }else if (marks <= 82.4) {
         System.out.println("Rank:excelent");
      }else {
         System.out.println("Rank:others");
      }
   }
}
                        

🖥 Program Output

Before swapping, a = 10 and b = 35
Before swapping(Inside), a = 10 b = 35
After swapping(Inside), a = 35 b = 10

**Now, Before and After swapping values will be same here**:
After swapping, a = 10 and b is 35
Press any key to continue . . .
                            
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.