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/
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Java String
Post your Comment