- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
What is the difference between character literals and string literals in Java?
Character literals represents alphabets (both cases), numbers (0 to 9), special characters (@, ?, & etc.) and escape sequences like
, \b etc.
Whereas, the String literal represents objects of String class.
Example
public class LiteralsExample { public static void main(String args[]){ char ch = 'H'; String str = "Hello"; System.out.println("Value of character: "+ch); System.out.println("Value of string: "+str); } }
Output
Value of character: H Value of string: Hello
- Related Articles
- What is the difference between data types and literals in Java?
- What is the difference between integer and floating point literals in Java?
- Character constants vs String literals in C#
- Type difference of character literals in C and C++
- What are Character Literals in C++?
- Type difference of character literals in C vs C++
- What are Perl String Literals?
- What are literals in Java?
- What are string literals in C#?
- What is the type of string literals in C and C++?
- What is the type of string literals in C/ C++?
- What are Boolean literals in Java?
- What are string literals in C language?
- Literals in Java programming
- Boolean Literals in Java

Advertisements