command prompt - Why cant we give array of values to a String in main function in Java? -


class helloworld{     public static void main(string args[4]){         system.out.println("hello world!");     } } 

is wrong give string args[4] ? why cant mention value inside string args[4] ?but should output hell,but there wrong.the code not executing properly.

you getting args parameter. array created when program runs. content of args array not known @ compile time (not size), therefore not make sense make assertions @ compile time size. reason array never contains length in type signature.

if need check size, correct way writing condition, such as:

if (args.length != 4) {     //do error handling stuff } 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -