0

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

I've seen some code which uses the ' ' version to subtract character values from each other which I didn't think was possible which got thinking as to what exactly they infer that is different?

What is the difference between " " and ' '? (How do they change how the code sees what ever is within the apostrophes / quotation marks etc.)

Community
  • 1
  • 1
John Smith
  • 231
  • 3
  • 12

2 Answers2

1

The difference is a matter of type. " " is a string literal, a Java String containing only a space character, and ' ' is a character literal, or a literal Java char. The String could contain 1 char, 2, 3, or more, and Strings are made up of an underlying array of char values like ' '.

pb2q
  • 58,613
  • 19
  • 146
  • 147
1

Single quoted variables such as ' ' are interpreted as a char, whereas double quoted variables such as " " is a String.

Chris Cashwell
  • 22,308
  • 13
  • 63
  • 94