javasyntax

Is there a difference between single and double quotes in Java?


Is there a difference between single and double quotes in Java?


Solution

  • Use single quotes for literal chars, double quotes for string literals, like so:

    char c = 'a';
    String s = "hello";
    

    They cannot be used any other way around (like in Python, for example).