How to loop through array using for loop in Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
        String[] arr = {"java", "c", "c++", "c#"};
        
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}




/*
run:

java
c
c++
c#

*/

 



answered May 23, 2021 by avibootz

Related questions

1 answer 246 views
1 answer 139 views
1 answer 163 views
3 answers 222 views
222 views asked Apr 8, 2021 by avibootz
4 answers 274 views
274 views asked Apr 4, 2021 by avibootz
1 answer 237 views
1 answer 210 views
...