I write the code System.out.println('\577');
and it produces unclosed character literal error. What's the problem here as all the digits are in the limits of the octal integers?
Asked
Active
Viewed 142 times
0

user12208242
- 315
- 1
- 11
-
What _char_ is `\577` supposed to be? – Tom Oct 13 '19 at 05:55
-
You need to escape back slash, System.out.println("\\577"); – Ruelos Joel Oct 13 '19 at 05:56
-
1Not sure if this still applies https://stackoverflow.com/questions/9543026/why-do-java-octal-escapes-only-go-up-to-255 but base on that octal only go up to 255. – Kevin Ng Oct 13 '19 at 06:11
-
1Your octal is too large. See also https://stackoverflow.com/questions/9543026/why-do-java-octal-escapes-only-go-up-to-255 – Henry Oct 13 '19 at 06:14
-
1Possible duplicate of [Why do Java octal escapes only go up to 255?](https://stackoverflow.com/questions/9543026/why-do-java-octal-escapes-only-go-up-to-255) – Tom Oct 13 '19 at 15:07
-
@KevinNg thanks...This solved – user12208242 Oct 17 '19 at 13:48
-
@user12208242 - You are welcome. – Kevin Ng Oct 17 '19 at 22:27
1 Answers
0
Just change it to System.out.println("/577");
. You are getting error because you are using ' '
for a String but single quot (' ') can't take more that a Character, So you need to use " "
(double quot) when you take into more than one character or string. Hope it works.

A S M Sayem
- 2,010
- 2
- 21
- 28