• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Little help with Java

Jacko28

New Member
Joined
Sep 23, 2008
Messages
67 (0.01/day)
I've began slowly learning java, however this morning I came to a halt, it's such a simple problem but I just can't get around it.

The line of code involves using escape seqeuences to put illiegal characters into a print.out statement.

"(\+\=\ \\)" ! help ! "{/&\is/\\}".

Basically I have to put this into a line of code but I cant seem to get the escape sequences to work. From what I've read by using \ you can input the characters.

Would it be ;

\"(\\+\\=\\ \\\\)\" ! but ! \"{/&\is/\\\\}\". - To me this seems wrong and to my compiler it is wrong :laugh:

Any help would be appreciated, many thanks

Jacko28
 

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.63/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
Only quotes (because they start and end a string declaration) and backslashes (because they define the escape character) need to be escaped:
string s = "\"(\\+\\=\\ \\\\)\" ! help ! \"{/&\\is/\\\\}\"";

You forgot the extra backslash before "is"
 
Top