Home Help Java S Java String
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Java String

Advertisement
In this section, you will learn about the java string. Java String is a set of characters such as the string "Hello".

Java String

     


In this section, you will learn about the java string.
Java String is a set of characters such as the string "Hello". It is a combination of H, e, l, l, o. All String literals are instances of this class and two string literals with the same contents refer to the same String object. A string can store a single word or more. 
 
The String class includes number of methods to edit the content of string. String is special-cased when doing data serialization - rather than listing the fields of this class, a String object is converted to a string literal in the object stream.

The Java String object contains a sequence of char values. A char represents a single character, such as 'a',  'A'. A char value is written in Java code using single quotes (') as shown here. Java supports the Unicode character set, so we are no limited to just roman A-Z characters. The char data type is a simple primitive data type, this is very similar to int, so use simple = to copy char values, and == and != to compare char values.

For creating a String object you use the "new" operator:

String str = new String("Hello");

To see more tutorials with running example to Java String:

http:/www.roseindia.net/java/string-examples/ 

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 16, 2009

Ask Questions?    Discuss: Java String  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Sahil Mahajan
June 9, 2012
Java Input Stream

Which Method is best for getting input from the Users. By using InputStreamReader method or the Scanner Class
DMCA.com