RUVIDEO
Поделитесь видео 🙏

2.Java Performance Tuning -2 loop jamming

For. Most runtime in programs is spent in loops. The for-loop iterates over numbers. It is commonly used. It is ideal for processing known ranges.

For each. In Java no foreach keyword is used. Instead we use the for-keyword to iterate over each element in a collection. We do not need an index to do this.

Recommendation. A for-loop is best when the starting and ending numbers are known. If the end index is unknown, consider a while-loop. Use a break when the end is reached.

For each. This is a simple syntax form. If we loop over a collection, we use a colon, not an index variable. This enumerates each element in the collection (array, ArrayList).

Break. A for-loop can be stopped at any time, based on any condition. We use the "break" statement. It takes no arguments and terminates the nearest enclosing loop.
Break
Tip:
More complex logic is needed to fully break out of a nested loop. A flag boolean, or the use of methods, is needed.

However:
This for-loop example scans each element in the values array. It stops (breaks) when a negative one element is found.

Continue. This keyword stops the current loop iteration and moves to the next one. Further statements are not executed. In a loop with an iteration condition, the next iteration begins.
Continue
Caution:
A continue statement can sometimes lead to an infinite loop. Be sure the iteration variable is incremented.

Nested for-loops. All kinds of loops can be nested. When we use a break or continue statement with a nested loop, only the innermost loop is affected.However:A return statement will exit all loops in the current method. Sometimes flag variables of boolean type are needed.

Performance, loop jamming. In loop jamming many loops are combined into one. Consider this program—three arrays, all of the same length, must be looped over.
Version 1:
The first part loops over the three arrays separately and sums their elements.

Version 2:
The second part loops over the arrays in a single, jammed loop. This version is faster.

Result:
The single loop is nearly twice as fast as the three loops put together. And it has the same result on every iteration.

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «2.Java Performance Tuning -2 loop jamming», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.