+ 2

question regarding arrays

instead of numbers can we use (name of array).length i m trying to do it but unable if not can u suggest some ways to initialise the capacity of array.

13th Apr 2017, 9:53 AM
shobhit
shobhit - avatar
4 Answers
+ 8
Enumeration is what you want to use for that
13th Apr 2017, 10:04 AM
Sachin Artani
Sachin Artani - avatar
+ 1
So you are saying instead of this for (int i=0; i<x; i++) this for (int i=0; nameOfArray.length<0;i++) If I understand your question correctly, yes you can do that, if I didn't, I am sorry.
13th Apr 2017, 10:46 AM
Alejandro Herrera
Alejandro Herrera - avatar
+ 1
Arrays are like semi dynamic datatypes. There are two types of array declaration in java: Type 1: int array[] = {1,2,3,4,5}; Type 2: int array[] = new int[4] where [4] initialize the size of array anyway this is the way i would do this: https://code.sololearn.com/cri1XRyTx4R9/#java
13th Apr 2017, 1:04 PM
( ͥ° ͜ʖ ͥ°)
+ 1
but what are enumeration.
13th Apr 2017, 2:53 PM
shobhit
shobhit - avatar