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 364 views
1 answer 239 views
1 answer 253 views
3 answers 387 views
387 views asked Apr 8, 2021 by avibootz
4 answers 452 views
452 views asked Apr 4, 2021 by avibootz
1 answer 327 views
1 answer 312 views
...