java中为按钮添加图片_如何在Java中为字符串添加双引号?

java中为按钮添加图片

  • In Java, everything written in double-quotes is considered a string and the text written in double-quotes is display as it is.

    在Java中, 双引号中的所有内容均视为字符串,而双引号中的文本按原样显示。

  • Suppose, if we want to add double quotes to a string then we need [\"] escape sequence to escape quotes.

    假设,如果要在字符串中添加双引号,则需要[ \“ ]转义序列来转义引号。

  • Let us suppose if we have a string "Preeti" and simply it will display like this preeti and if we want to add double quotes to string (i.e. display like "preeti" ) then we will write a statement like this "\"Preeti\"".

    让我们假设,如果我们有一个字符串“ Preeti”,并且简单地将显示为这样的preeti,并且如果我们想在字符串中添加双引号(例如,显示为“ preeti” ),那么我们将编写一个这样的语句: “ \” Preeti \ ”

We will understand this thing with the help of an Example...

我们将借助“示例”来理解这件事。

Example:

例:

public class AddQuotesToString {
    public static void main(String[] args) {
        // Create a string named str1 with value Java 
        // and display like this Java.
        String str1 = "Java";
        
        // Create a string named str2 with value OOPS 
        // and display like this Java "OOPS".
        // For adding double quotes to OOPS  
        // then we need or add \" escape sequence to escape quotes 
        // around both side string.
        String str2 = " \" OOPS \" ";
        System.out.println("Display String without quotes " + " " + str1);
        System.out.println("Display String with quotes " + " " + str2);
    }
}

Output

输出量

D:\Programs>javac AddQuotesToString.java

D:\Programs>java AddQuotesToString
Display String without quotes  Java
Display String with quotes   " OOPS "


翻译自: https://www.includehelp.com/java/how-to-add-double-quotes-to-a-string-in-java.aspx

java中为按钮添加图片

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值