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 239 views
1 answer 132 views
1 answer 152 views
3 answers 206 views
206 views asked Apr 8, 2021 by avibootz
4 answers 259 views
259 views asked Apr 4, 2021 by avibootz
1 answer 224 views
1 answer 201 views
...