8) Methods
Create and use a static method that returns a value.
← All Topics
▶ Run Program
Java Code
public class Main { static int square(int n) { return n * n; } public static void main(String[] args) { System.out.println("Square of 6 = " + square(6)); } }
Program Input (optional)
Output