//Code=java//
Here is the code of call by value and call by reference
When i compile test.java file , It compiles and gives me a run time error main method not found in test ,please define the main method as public static void main(String args[])class test { void meth (int a,int b) { a*=2; b/=2; } } class callbyvalue { public static void main(String[] args) { test ob=new test(); int i=15,j=20; System.out.println("i and j before call :" +i + " " +j); ob.meth(i,j); System.out.println("i and j after call : " + i + " " +j); } } class test1 { int a,b; test1 (int i, int j) { a=i; b=j; } void meth(test1 o) { o.a*=2; o.b/=2; } } class callbyref { public static void main (String args[]) { test1 ob=new test1 (15,20); System.out.println("ob.a and ob.b before call: " +ob.a +" " + ob.b); ob.meth(ob); System.out.println("ob.a and ob.b after call : "+ob.a +" "+ob.b); }
On the other hand , when i am compiling test1.java, it is also giving the same error.My question is main method is there in both the codes . So what do we mean by this error?
Why is it so? Please help me resolve both as i have exam . Thanks
//Code=Java