Java array creation

This is just a simple question. I can't find the answer in the document!

String args[] = new String[0];
args[0] = "test";

Is that right? Will this create an array of 1 or 0 elements?

Thank you. I know this is a stupid question, but I can't find the answer in Java doc

Solution

This will create an array of length 0 The second line gives an arrayindexoutofboundsexpectation

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>