How to enter quotes in a Java string?

后端 未结 10 1163
不知归路
不知归路 2020-11-22 05:38

I want to initialize a String in Java, but that string needs to include quotes; for example: \"ROM\". I tried doing:

String value = \" \"ROM\" \         


        
10条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 06:02

    Here is full java example:-

    public class QuoteInJava {     
    
    public static void main (String args[])
        {
                System.out.println ("If you need to 'quote' in Java");
                System.out.println ("you can use single \' or double \" quote");
        }
    }
    

    Here is Out PUT:-

    If you need to 'quote' in Java
    you can use single ' or double " quote
    

提交回复
热议问题