在 Java 中将 null 连接到字符串
若要将 null 连接到字符串,请使用 + 运算符。
假设以下内容是我们的字符串。
String str = "Demo Text";
现在,我们将了解如何轻松地将 null 连接到字符串。
String strNULL = str + "null";
以下是最终示例。
示例
public class Demo { public static void main(String[] args) { String str = "Demo Text"; System.out.println("String = "+str); String strNULL = str + "null"; System.out.println("String concatenated with NULL: "+strNULL); } }
输出
String = Demo Text String concatenated with NULL: Demo Textnull
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP