What does “String[] args” contain in java?

后端 未结 8 1888
终归单人心
终归单人心 2020-12-15 08:18

When I run the following program:

public class Test
{
    public static void main(String[] args)
    {
        System.out.println(args);
    }
{
8条回答
  •  余生分开走
    2020-12-15 08:40

    Lets make it simple

    1: Write a simple class named "test"

    public class test {
        public static void main(String[] args) {
            System.out.println("Passed argument is: " + args[0]);
        }
    }
    

    2: Now compile it in the following way

    javac test.java
    

    3: Now run this by passing an argument

    java test Ayoub
    

    ** the output will be**

    Passed argument is: Ayoub
    

提交回复
热议问题