Skip to main content
fixed the incorrect one line comment syntax - replaced \\ with //
Source Link
sactiw
  • 22.6k
  • 4
  • 44
  • 28

Below are various ways to convert to char c to String s (in decreasing order of speed and efficiency)

char c = 'a'; String s = String.valueOf(c); \\// fastest + memory efficient String s = Character.toString(c); String s = new String(new char[]{c}); String s = String.valueOf(new char[]{c}); String s = new Character(c).toString(); String s = "" + c; \\// slowest + memory inefficient 

Below are various ways to convert to char c to String s (in decreasing order of speed and efficiency)

char c = 'a'; String s = String.valueOf(c); \\ fastest + memory efficient String s = Character.toString(c); String s = new String(new char[]{c}); String s = String.valueOf(new char[]{c}); String s = new Character(c).toString(); String s = "" + c; \\ slowest + memory inefficient 

Below are various ways to convert to char c to String s (in decreasing order of speed and efficiency)

char c = 'a'; String s = String.valueOf(c); // fastest + memory efficient String s = Character.toString(c); String s = new String(new char[]{c}); String s = String.valueOf(new char[]{c}); String s = new Character(c).toString(); String s = "" + c; // slowest + memory inefficient 
adding one more way ...
Source Link
sactiw
  • 22.6k
  • 4
  • 44
  • 28

Below are various ways to convert to char c to String s (in decreasing order of speed and efficiency)

char c = 'a'; String s = String.valueOf(c);  \\ fastest + memory efficient String s = Character.toString(c); String s = new String(new char[]{c}); String s = String.valueOf(new char[]{c}); String s = new Character(c).toString(); String s = "" + c;  \\ slowest + memory inefficient 

Below are various ways to convert to char c to String s (in decreasing order of speed and efficiency)

char c = 'a'; String s = String.valueOf(c); \\ fastest + memory efficient String s = Character.toString(c); String s = new String(new char[]{c}); String s = String.valueOf(new char[]{c}); String s = "" + c; \\ slowest + memory inefficient 

Below are various ways to convert to char c to String s (in decreasing order of speed and efficiency)

char c = 'a'; String s = String.valueOf(c);  \\ fastest + memory efficient String s = Character.toString(c); String s = new String(new char[]{c}); String s = String.valueOf(new char[]{c}); String s = new Character(c).toString(); String s = "" + c;  \\ slowest + memory inefficient 
Source Link
sactiw
  • 22.6k
  • 4
  • 44
  • 28

Below are various ways to convert to char c to String s (in decreasing order of speed and efficiency)

char c = 'a'; String s = String.valueOf(c); \\ fastest + memory efficient String s = Character.toString(c); String s = new String(new char[]{c}); String s = String.valueOf(new char[]{c}); String s = "" + c; \\ slowest + memory inefficient