First of all, I noticed that you are trying to use nested functions in Java, sadly, they are not at all supported in the Java language.
public Test1() {
public static void test (int num1,int num2,int num3) {
You need to terminate the constructor, and then start another function. There is a concept of
lambda functions[
^], but that is something else.
Another thing that I saw in your code was that you are not following the standards for main function in Java programs. If you read the standard for
Java's main function[
^], you will find out that the function has to be declared as,
public static void main(String[] args) { }
This is the standard that your program
must follow. Try the following code instead,
public class Test1 {
public Test1() {
}
public static void main(String[] args) {
test(0, 0, 0);
}
public static void test (int num1,int num2,int num3) {
num1= 20 ;
num2= 22 ;
num3= num1+num2 ;
System.out.println(num3);
}
}
This should work, unless your Java compiler is expecting another class to be the main class for your program. Secondly, start learning Java from here,
Trail: Learning the Java Language (The Java™ Tutorials)[
^], I really enjoyed learning the Java basics from here and apply them in NetBeans. NetBeans is a simple IDE for Java beginners, Eclipse can be hard sometimes.
For more, please look:
Lesson: A Closer Look at the "Hello World!" Application (The Java™ Tutorials > Getting Started)[
^]