Suppose I have an array containing elements that are related to its indexes, but I don't need (won't ever have to) access all of its elements. For example, I may never need to access the zeroth element. Are there any "rules of thumb" for when to use any one of these in preference to the others:
I wonder if the second choice will even compile. The advantage of the third over the first is that you avoid creating a String object. Any time you can avoid creating extra unnecessary objects, you're better off.
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Yes, the second choice will compile and run; I've used it. The reason I asked the question is that the instructor's solution for one of the "java in general" assignments uses 2 arrays: the first choice is used in one of the arrays and the third choice is used in another of the arrays. So I wondered ...