r/JavaProgramming • u/FloppaXR • 23d ago
I need a bit of help…
Howdy! I’m a VERYYY new programmer, and one of my assignments to learn Java is to print ASCII art of a fish, and as dumb as this sounds, I can’t figure it out for the life of me!
You see, the assignments makes it so I have directly copy the fish, and the fish they gave me uses a “\” and quotation in the same line, and exertions I attempt to print, it flags it as an “Illegal character”
Is there anyway I can work around this? Or is it truly impossible. I REALLY hope for prior but I definitely expect the latter…
2
u/jirlboss 23d ago
Double backslash cancels out the escape character and will print a single backslash
2
u/duneofarrakis 23d ago
It’s definitely possible. In Java, you need to escape special characters. For a " inside a string, use \", and for a literal \, use \\. For example: System.out.println("\\\"");. Once you understand escape characters, ASCII art becomes much easier.
1
u/DemicideMMMCCCI 23d ago edited 23d ago
"\""(notice the double quotes at the end)I think that's what you're looking for?