Most efficient way to convert a single char to a CharSequence

Graham Borland picture Graham Borland · Jul 6, 2011 · Viewed 44.8k times · Source

What's the most efficient way to pass a single char to a method expecting a CharSequence?

This is what I've got:

textView.setText(new String(new char[] {c} ));

According to the answers given here, this is a sensible way of doing it where the input is a character array. I was wondering if there was a sneaky shortcut I could apply in the single-char case.

Answer

eljenso picture eljenso · Jul 6, 2011
textView.setText(String.valueOf(c))