Java Beginner Question : What is wrong with the code below ?
- by happysoul
public class Function
{
public static void main(String args[])
{
System.out.println(power(3,2));
System.out.println(power(3,2));
System.out.println(power(2));
}
public long power(int m)
{
return m*m;
}
public long power(int m,int n)
{
long product=1;
for(int i=1;i<=n;i++)
{
product=product*m;
}
return product;
}
}
Compiler displays this error :-
Function.java:5: non-static method power(int,int) cannot be referenced from a static context