how to take large size array in java

后端 未结 6 1186
醉话见心
醉话见心 2021-01-26 07:05

i am new to java and i want to take large input size array in java. but in gives me some Runtime Error - NZEC, I don\'t know about it and i also did some research on this error

6条回答
  •  旧时难觅i
    2021-01-26 07:20

    Array sizes are limited to int size (i.e. about 2 billion). You're trying to initialize one with long. Either read the size into an int or cast the long with long a[]=new long[(int)n];.

    I recommend the former to avoid any subtle bugs.

提交回复
热议问题