Invalid character constant in Java
return (int) (feetPart) + '\' ' + inchesPart + '\''+'\'';
return (int) (feetPart) + '\' ' + inchesPart + '\''+'\'';
Why the above invalid characters remain unchanged, which works perfectly in JavaScript I want to display the height in feet and inches and use this client, but when I use the same on the server, it displays invalid character constants
Solution
Because of this part:
'\' '
That's an attempt to specify one character. The text is actually two characters (apostrophe and space) Character text must be one character
If you want to specify an apostrophe space, you should use string text – the apostrophe does not have to be escaped:
"' "
Your whole presentation will be better:
return (int) (feetPart) + "' " + inchesPart + "''";
Or use "instead of" to represent inches:
return (int) feetPart + "' " + inchesPart + "\"";
Note that I don't even know if the original code will perform the operation you want at compile time, because I suspect it will perform integer operations on feetpart and characters
Your code works well in JavaScript because both single and double quotation marks are used for string text