Dear Learner,
Hope you are doing great.
Your code needs little bit correction.
Please use the below given code :
package first;
import java.util.Scanner;
public class testfunctions {
static int square(int x)
{
int y=x*x;
return y;
}
public static void main(String[] args) {
Scanner in =new Scanner(System.in);
System.out.println("Enter the number : ");
int n=in.nextInt();
int result=testfunctions.square(n);
System.out.println("Square of "+n+" is : "+ result);
}
}
Please try the above code and let us know if you face any issue.
We will be waiting for your response.