Search code examples
javaparametersshareprogram-entry-pointargs

Length of args in Java


What is the length of main's args in Java? is it dynamic? I want to pass parameters between two main methods, can I send any number of String arguments?


Solution

  • I came up with this conclusions:

    1. args as any arrays is static not dynamic, but it's length is determined at run-time, and this doesn't make it dynamic anyway.
    2. we can pass (not send) arguments to other main method as it's just like any other method, it doesn't create a new thread.

    I was thinking that calling main method would run another thread, that was just somehow stupid.

    it's just executed in the memory of the caller thread, if we want to pass variables between two thread, we can use sockets

    Edit

    After nearly 20 months, here I'm back to this thread again, to correct my misconceptions about Java language.