0
why cant the argument inside main method cannot be changed to int() in the given example snippet??
8 Answers
+ 1
You can use int type whenever you declare a variable or parameter that will always receive only integer values. For example, int age;
Generally, you use int values inside your program, not with values that came from user input or command line. Ahead on the course you will probably see more examples.
0
How can I see the snippet? I don't see context.
0
//sorry for the inconvenience this is the snippet: class MyClass {
static void sayHello() {
System.out.println("Hello World!");
}
public static void main(String[ ] args) {
sayHello();
}
}
0
Which argument? If you're referring to String[], it is because Java demands main method to have this specific signature. Is that your doubt?
0
s
0
why cant the argument be int??
0
Because it is supposed to receive arguments from command line, that could be any string. So the type is to reflect a list of strings.
0
if so, then where can we use integer type??