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");
}
}
}
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 . . .
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.
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.