Determining number of array elements without having to manually count them.
in
Programming Questions
•
2 months ago
Hey, I am trying to implement a code which requires a long list of elements in an array, maybe 300 or above... But each time I make some changes, I have to change the number of times a loop is to run since I am increasing the number of elements. Is there a function or some automatic way to make the program change the integer value by itself if I simply insert a variable in its place? Since counting upto 300 and beyond can be quite painstaking...
For example, take this array.
String[] var = {
"Hello","Bye"};
I know that there are two elements in this... If I didn't, then how could I make the application figure it out on it's own?
1