0 day streak
java / beginner
Snippet

Using Method Parameters

Parameters allow you to pass information into methods so they can perform tasks with different data.

snippet.java
java
1
2
3
void displaySum(int a, int b) {
System.out.println(a + b);
}
Breakdown
1
void displaySum(int a, int b)
Defines a method that accepts two integers named 'a' and 'b'.
2
a + b
The parameters are used inside the method body like local variables.