c#格式化字符串cout的Java等价语句

本文关键字:语句 Java 格式化 字符串 cout | 更新日期: 2023-09-27 17:49:40

下面语句的Java等价指令是什么?

String name;
cout << "So your name is  " << name << endl;  

或者c#

console.writeline("So your name is {0} ", name);

c#格式化字符串cout的Java等价语句

String name;
cout<<"So your name is  "<<name<<endl; 

等价于:

String name = ...;
System.out.println("So your name is " + name);

:

Console.WriteLine("So your name is {0}", name);

等价于:

System.out.printf("So your name is %s", name);