the difference of String.valueOf(char) and +

Posted by Will Yu on Stack Overflow See other posts from Stack Overflow or by Will Yu
Published on 2012-09-25T15:30:28Z Indexed on 2012/09/25 15:37 UTC
Read the original article Hit count: 106

Filed under:
|
|
|

to show the default value of char ,I wrote code like this:

public class TestChar {
  static char a;
  public static void main(String[] args) {
    System.out.println("."+String.valueOf(a)+".");
    System.out.println("the default char is "+a);
  }   
}

but the console output is confused.the first is ". ." ,however the second is "the default char is [](like this ,I don't know how to describe it.)" why?thanks for help

© Stack Overflow or respective owner

Related posts about java

Related posts about string