Monday, February 28, 2011

Convert char array to a string in java (Simple example)

In Java it is very easy to convert a char array in to a string. In String class there is a constructor you can pass a char array. See following simple example.

  char [] cArray = { 'I',' ','L','o','v','e',' ','J','a','v','a' };
  String text = new String(cArray);
  System.out.println(text);

No comments:

Post a Comment