+ 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.
4 ответов
+ 8
Enumeration is what you want to use for that
+ 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.
+ 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
+ 1
but what are enumeration.