Step 3 - Difference in C and Java command line arguements
1. Main method signatures
C
int main(int argc, char *argv[]) //<---- NOTE
{
...
}
Java
public class Lab9
{
public static void main (String[] args) //<---- NOTE
{
.....
}
}
2. Contents of the arguement array
C
Consider the following command line run for C program named Echo. Observe the contents of argv[] array
Echo Drink hot Java
argv[0] -> Echo ie. the name of the program
argv[1] -> Drink
argv[2] -> Hot
argv[3] -> Java
Java
Consider the following command line run for Java program names Echo. Observe the contents of args[] array.
java Echo Drink Hot Java
args[0] -> Drink
args[1] -> Hot
args[2] -> Java