public class Test {


    public static void main(String[] args) {
        String line=".Raghu";
        System.out.println(line);
        char[] h= line.toCharArray();
        char[] f=null;
        int c=0;
        if(h[0]=='.')
        {
            for(int i=0; i<h.length; i++){
            f[c]= h[i];
            System.out.println(f[c] + h[i]);
            c++;
        }
        f[c]='\0';

    }
    }
}

Edited 3 Years Ago by Reverend Jim: Fixed formatting

Welcome sneharaveendran,

Please read http://www.daniweb.com/forums/announcement9-3.html before to post your problem.

I have re-write your code and add comments where it is required.

public class Test {
public static void main(String[] args) {
    String line=".Raghu";
    System.out.println(line);
    char[] h= line.toCharArray();

 //    char[] f=null;   // it is a cause of an error - NullPointerException
     char []f=new char[h.length];
    int c=0;
    if(h[0]=='.')
         {
           for(int i=0; i<h.length; i++){
                   f[c]= h[i];
                   System.out.println(f[c] + h[i]);
                    c++;
          }
   // f[c]='\0';  // No need - array index will be exceed. 
   }
  }
}
This article has been dead for over six months. Start a new discussion instead.