Splitting the String TO Character Array using JAVA.........

Hi Friends this program will demonstrate the How to "Split String to Character Array".

Save the File SpiltStringTOCharArray.java

class SpiltStringTOCharArray
{
public static void main(String[] args)
{
String msg = "HELLO";
char a[]=msg.toCharArray();
                int i=0;
        
for( i=0;i<msg.length();i++)
              {
                   a[i]=msg.charAt(i);
           System.out.println("a["+i+"] value is : "+a[i] );
               }
}
}

OUTPUT :

a[0] value is : H
a[1] value is : E
a[2] value is : L
a[3] value is : L

a[4] value is : O

I hope this LOGIC will help full to all........


EmoticonEmoticon