开发者

This code should give output as the given format [closed]

开发者 https://www.devze.com 2023-04-10 09:35 出处:网络
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this po
Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 9 years ago.

Improve this question 开发者_Go百科

This is code in java for string.

int a=6;
int b=7;

System.out.println(a+"\"+b);

I want to comes the output is 6\7.


write this code:

System.out.println(a+"\\"+b);


In literal Java strings the backslash is an escape character. The literal string "\\" is a single backslash.

In regular expressions, the backslash is also an escape character. The regular expression \\ matches a single backslash. This regular expression as a Java string, becomes "\\\\". That's right: 4 backslashes to match a single one.

0

精彩评论

暂无评论...
验证码 换一张
取 消