Print double quotes in java

Print double quotes in java

💡 Outline
You can print double quotes in java by escape double quotes using backslash character(\).

When you print on console using System.out.println, you use double quotes and whatever value inside double quotes is printed. But what if you want to actually print double quotes on console.

In this tutorial, we will see different method to print quotation marks in java.

Print double quotes in java using backslash character

You can use backslash character(\) to escape the double quotes and it will be printed on the console.

Output:

“Hello world from java2blog”

Print double quotes in java using unicode character

You can use unicode character of double quotes and append it to String to print quotation marks in java.
unicode character of double quotes is \u0022, so we will append this unicode character in the string.
Example

Output:

“Hello world from java2blog”

As you can see, when we printed the string, unicode characters converted into double quotes. That’s how you can print quotation marks in java.

Print double quotes in java by appending double quote character

You can put double quote in single quotes to convert it to character and append to the string to print quotation marks in java.
Example

Output:

“Hello world from java2blog”

That’s all about how to print double quotes in java.

Related Posts

  • 13 July

    Remove substring from String in Java

    Table of ContentsUsing String’s replace method to remove substring from String in JavaUsing String’s replaceFirst method to remove substring from String in JavaUsing String’s replaceAll method to remove substring from String in JavaUsing StringBuilder’s delete() method to remove substring from String in JavaUsing StringBuilder’s replace() method to remove substring from String in JavaConclusion In this […]

  • Java String contains IgnoreCase
    23 June

    Java String contains Ignore Case

    Table of ContentsUsing String.toLowerCase()Using Pattern.compile()Using String’s MatchesUsing StringUtils.containsIgnoreCase()Complete program for Java String contains IgnoreCaseConclusion We often have to check if a string contains a substring or not in a case-insensitive manner. There are multiple ways to do so. In this article, we will take a look at these methods for java String contains Ignore Case […]

  • Find and count occurences of substring in String in Java
    02 June

    Find and count occurrences of substring in string in java

    Table of ContentsUsing the indexOf() methodUsing regular expressionUsing split() methodUsing the countMatches() method from Apache Commons library In this post, we will see how to find and count occurrences of substring in string in java. Using the indexOf() method The indexOf() method in java is a specialized function to find the index of the first […]

  • Java Split String by Space
    13 May

    Java split string by space

    Learn about how to split String in java in different ways.

  • Split String by new line in java
    09 May

    How to split String by newline in java

    Learn about how to split String by newline in java

  • 15 April

    How to declare a String array in java

    Learn about how to declare String array in java.

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.