public class MyClass {
public static void main(String[] args){
//A method is a block of code which only runs when it is called
sayHello(name:"Raj",age:20);
}
//method should be defined in the class
public static void sayHello(String name, int age){
System.out.println("Hello!");
}
}
This code is returning folowwing errors for line 7: ')' expected ';' expected 'not a statement'
I had expected the code to run as is should but I can't seem to identify the error.
in java there is no named- but positional-parameters only
so this is invalid:
sayHello(name:"Raj",age:20);
do instead:
sayHello("Raj", 20);