0
Even & Odd Indices of a string
I have a query. If wanting to print/output ONLY the odd or even indices of a user input string (in Java) is there an inbuilt Java function to do so (similar to charAt()), or do I have to use a for loop?
1 Odpowiedź
+ 3
There isn't something built in the Java libraries for this. You must either use a loop or recursion for it. The loop being the fastest and most understandable method. But, coding it via recursion would be a great learning experience.