Possible Duplicate:
Causes of 'java.lang.NoSuchMethodError: main Exception in thread “main”'
i am new in java.i want to write a program to swap 2 nos.
i have written 2 programs on it.one is running and other is not.
i cant understand the fault of the not running program.pls help me to understand my fault.
here i giving you both the programs along with the output.
the running program:
public class SwapElementsExample {
public static void main(String[] args) {
int num1 = 10;
int num2 = 20;
System.out.println("Before Swapping");
System.out.println("Value of num1 is :" + num1);
System.out.println("Value of num2 is :" +num2);
swap(num1, num2);
}
private static void swap(int num1, int num2) {
int temp = num1;
num1 = num2;
num2 = temp;
System.out.println("After Swapping");
System.out.println("Value of num1 is :" + num1);
System.out.println("Value of num2 is :" +num2);
}
}
the output is:
before swapping
value of num1 is : 10
value of num2 is : 20
after swapping
value of num1 is : 20
value of num2 is : 10
in the above mentioned program i have not any problem.
but in the next program what is the fault i cannot find.
pls help me to find the error.
class Swap
{
public static void main(int a, int b)
{
int c=0;
c=b;
b=a;
a=c;
c=0;
System.out.println(a);
System.out.println(b);
}
}
in the execution there is no error msg.
but in runtime there is a error msg and that is:
exception in thread "main" java.nosuchmethoderror:main
pls let me know the problem of this program.