You are here: Home / Topics / Advance for loop example in Java

Advance for loop example in Java

Filed under: Java on 2023-08-18 06:52:19

public class AdvancedForLoop {

   public static void main(String[] args) {
      
       String s1 = "INDIA";
       char s2[] = new char[s1.length()];

       for (int i = 0; i < s1.length(); i++) {
           s2[i] = s1.charAt(i);
       }

       for (char e : s2) {
           System.out.println(e);
       }
   }
}


Output:

INDIA

About Author:
Y
Yatendra Sir     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.