why this code is showing errors and not compiling please help!!!
Abhisheksharm28 (0)

class Main {
public int addThem(int x,int y) {
return x + y;
public double addThem(double x,double y){
return x + y;
public class NewAdder{
public static void main(String [] args){
Main a=new Main();
int a=23;
int b=34;
int result=a.addThem(a,b);
double doubleresult=a.addThem(22.4,33.5);

You are viewing a single comment. View All
Answered by blonkm (9) [earned 5 cycles]
View Answer
blonkm (9)

@Abhisheksharm28 I did so because Adder was part of Main and Java told me I can't reference Adder from within like that. This is a limitation of Java. So now I have instead moved Adder to its own file, and removed the static keyword. All is still working, proving you don't need static at all (except for the main method, which is called once and thus needs to be defined as static).