Java While Loop Through Array React