Please enable JavaScript to use CodeHS

CodeHS Glossary


Parameter Java

A variable passed into a method from outside the method. A parameter is an input into a method. For example, in the short program below, the `square` method takes in one parameter, an int named x. The run method passes the variable `num` to the `square` method as a parameter, so the value of `num` is copied over into the parameter `x`. ``` public class ParameterExample extends ConsoleProgram { // The run method takes no parameters as input public void run() { int num = 5; // Call the method square. Pass in num as a parameter. This will print out 25. square(num); } // The square method takes in one int as a parameter, and prints out the square of that parameter private void square(int x) { System.out.println(x * x); } } ```