- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to display double and single quote in a string
The following are our strings with single and double quote.
String str1 = "This is Jack's mobile"; String str2 = "\"This is it\"!";
Above, for single quote, we have to mention it normally like.
This is Jack's mobile
However, for double quotes, use the following and add a slash in the beginning as well as at the end.
String str2 = "\"This is it\"!";
The following is an example.
Example
public class Demo { public static void main(String[] args) { String str1 = "This is Jack's mobile"; String str2 = "\"This is it\"!"; System.out.println("Displaying Single Quote: "+str1); System.out.println("Displaying Double Quotes: "+str2); } }
Output
Displaying Single Quote: This is Jack's mobile Displaying Double Quotes: "This is it"!
- Related Articles
- Difference between single quote (‘) and double quote (“) in PowerShell?
- Java Program to Extract a Single Quote Enclosed String from a Larger String using Regex
- How to add a string containing double quote to records in MySQL?
- How to display a single quote text as a column value in MySQL?
- Java Program to convert String to Double
- C program to print a string without any quote in the program
- How to remove single quote from string column in an R data frame?
- How to Convert Double to String to Double in Java?
- Java Program to convert Double into String using toString() method of Double class
- Convert double to string in Java
- Convert String to Double in Java
- Compare two double arrays in a single line in Java
- Convert double value to string in Java
- Convert a String to a double type number in Java
- How to convert a double value to String in Java?

Advertisements