Java中字符串的拼接和转义
2021-07-03 23:04
标签:term code java process stat demo ado test pac Java中字符串的拼接和转义 标签:term code java process stat demo ado test pac 原文地址:http://blog.51cto.com/59465168/2173192package com.testToken.demo;
public class Test {
public static void main(String[] args) {
String str="Apple";
System.out.println(str);
String str2="\"Apple\""; //输出"Apple"
System.out.println(str2);
String str3="A apple \"pie\" ";
System.out.println(str3);
String str4="\\Apple";
System.out.println(str4);
String flag="true";
String token="123";
String res="{\"flag\":"+flag+",\"token\":\""+token+"\"}";
System.out.println(res);
String res2="{\"flag\":\"" +flag+"\",\"token\":\""+token+"\"}";
System.out.println(res2);
}
}