Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » FundamentalRSS Feeds

Strings and characters

Posted By: Ollie Moreno     Category: Java     Views: 1563

This article describes strings and characters in java with examples.

What is string in java?

Strings are easily defined by enclosing a series of characters between double quotes. Strings may be of any length, but they cannot include a line break. Java strings are not null-terminated. 

To include a double quote within a string, precede the double quote by a backslash character. In this context, the backslash prevents the compiler from treating the double quote as a termination for the string.

To declare and initialize a variable of type string refer below example.

String s = "This is my string variable."; 

After execution of this statement string variable having name 's' contains the string "This is my string variable.". It can be used anywhere where you can use a string.  


What is character in java?

Java characters are 16 bit unicode characters. Unicode is a character set that can accommodate many different human languages. This enables developers to write java applications that can work for international audiences. 

A character literal is enclosed by single quotes. For example,

char c = 'V';   



  
Share: 


Didn't find what you were looking for? Find more on Strings and characters Or get search suggestion and latest updates.

Ollie Moreno
Ollie Moreno author of Strings and characters is from Los Angeles, United States.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!