package com.java.myapp;
public class MyClass {
public static void main(String[] args) {
String country = "Belgium,France,Italy,Germany,Spain";
String[] arr = country.split(",");
for(String a:arr)
{
System.out.println(a);
}
System.out.println("===================");
for(int i=0; i<arr.length; i++)
{
System.out.println("Value index["+i+"] = " + arr[i]);
}
}
}
Output
Belgium
France
Italy
Germany
Spain
===================
Value index[0] = Belgium
Value index[1] = France
Value index[2] = Italy
Value index[3] = Germany
Value index[4] = Spain