Java String

classic Classic list List threaded Threaded
1 message Options
kumar kumar
Reply | Threaded
Open this post in threaded view
|

Java String

What is a string?
In C, C++, a string represents an array of characters (last character ends with ‘\0’).
In Java, a string represents the object of String class. We also have character array in java.

Is String a class or a datatype?
String is a class defined in java.lang package. In Java, every class is considered as user defined data type. So we can take string as a data type.

Ways to create a String:
Method 1:  By assigning a group of characters to a string type variable.
Syntax:

String <variable_name>;
<varaible_name> = “string”;
Example:
String name;
name = “Hari”;
Declaration and assignment can be made by a single statement. This is just a simplification of the above.

Syntax:

String <variable_name> = value;
Example:
String name = “Hari”;

To know more about Java Strings Please visit the following url..

http://www.javaprepare.com/java-tutorial/java-string/