developer

Java 8 Iterable.forEach() vs foreach loop

Question: ❓❓❓ Which of the following is better practice in Java 8? Java 8: joins.forEach(join -> mIrc.join(mSession, join)); Java 7: for (String join : joins) { mIrc.join(mSession, join); } I have lots of for loops that could be “simplified” with lambdas, but is there really any advantage of using them Read more…

By admin, ago
developer

Loop through an array in JavaScript

Question: ❓❓❓ In Java you can use a for loop to traverse objects in an array as follows: String[] myStringArray = {"Hello", "World"}; for (String s : myStringArray) { // Do something } Can you do the same in JavaScript? Good Answer: 👌👌👌 Use a sequential for loop: var myStringArray Read more…

By admin, ago