Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (13.1k points)
Can anyone help me how I can able to loop through all the entries present in an array? I was tried with forEach, but it is not working. Can anyone help me with this?

1 Answer

0 votes
by (26.7k points)

Basically, there are multiple ways to do that:

Using forEach:

var arr = ["a", "b", "c"];

arr.forEach(function(entry) {



Using for:

var i;

var arr = ["a", "b", "c"];

for (i = 0; i< a.length; ++i) {



You can go for simple "For" loop.

I hope this will help.

Want to know more about Java? Watch this video on Java Tutorial | Java Course:

Want to become a Java expert? join Java Training now!!

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jan 27, 2021 in Java by dante07 (13.1k points)
0 votes
1 answer
0 votes
1 answer
asked Mar 4, 2021 in Java by dante07 (13.1k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.7k questions

32.8k answers


109k users

Browse Categories