Skip to content
Advertisement

Tag: escaping

Java – Forward Slash Escape Character

Can anybody tell me how I use a forward slash escape character in Java. I know backward slash is but I’ve tried / and / / with no luck! Here is my code:- Thanks in advance! Answer You don’t need to escape forward slashes either in Java as a language or in regular expressions. Also note that

How can I make Java print quotes, like “Hello”?

How can I make Java print “Hello”? When I type System.out.print(“Hello”); the output will be Hello. What I am looking for is “Hello” with the quotes(“”). Answer The double quote character has to be escaped with a backslash in a Java string literal. Other characters that need special treatment include: Carriage return and newline: “r” and “n” Backslash: “\” Single

Java: Literal percent sign in printf statement

I’m trying to add an actual percent sign into a printf statement in Java and I’m getting the error: I can’t figure out how to put an actual percent sign into my printf? I thought using % to escape it would work, but it isn’t. Any ideas? Answer The percent sign is escaped using a percent sign: The complete syntax

Advertisement