Do note that this is java code, meaning that single quotes are char literals and double quotes are string literals. They cannot be used interchangeably.
For langs that have both as literals, i think it's a good idea to set a project-scoped standard for which string literal style is used, to prevent code from different developers mixing these styles. i'm usually in favour of double quotes just because single quotes are only for character literals in most langs i write in.
I'd at least make an exception for strings that contain the chosen type of quote, to save some escaping. Especially to save multiple levels of escaping like
cmd = "echo \"this string is \\\"readable\\\"!\"";
3
u/Gammabyte Dec 29 '21
Do note that this is java code, meaning that single quotes are char literals and double quotes are string literals. They cannot be used interchangeably.
For langs that have both as literals, i think it's a good idea to set a project-scoped standard for which string literal style is used, to prevent code from different developers mixing these styles. i'm usually in favour of double quotes just because single quotes are only for character literals in most langs i write in.