0

Can you help me how to convert this for loop to Enhanced For-Loop?

Thanks

for (int x = 0; x < grade.length; ++x)

		if (grade[x]==grade1)
		
		{
		
		gradesum = score [x] * testscore1;
		
		}

Edited by mehnihma: n/a

4
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by masijade
0

since in an enhanced for loop, you won't automatically have the x which you use as index for score and which, I assume, link the element in score to the element in grade, what do you want it for?

0

Do you know for sure that it's possible and/or sensible to convert it? At first sight I can't see a sensible way to do it, and I would keep the loop you've currently got.

0

You would first need to convert your parallel array structure to a map or a single array of objects that contain both values.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.