String:
String is a sequence of characters and it is widely used in Java.
First thing which we need to know about string in Java is that, it is not a primitive data type.
String is one of the predefined class that is implemented in Java. It helps to handle the strings in a required way.
We have to create an object or reference variable for the String class.
Syntax:
String str = new String();
String Constructors:
There are many constructors in String class. Now we will see the most important ones.
String is a sequence of characters and it is widely used in Java.
First thing which we need to know about string in Java is that, it is not a primitive data type.
String is one of the predefined class that is implemented in Java. It helps to handle the strings in a required way.
We have to create an object or reference variable for the String class.
Syntax:
String str = new String();
String Constructors:
There are many constructors in String class. Now we will see the most important ones.
- String( ) - Initialises the String object with no values in it.
- String(String str) - Initialises the String object with the values in str.
- String(byte[ ] b) - Initialises the String object using byte array b. Normally a byte stores numerical value. In this when we pass a byte array, the numerical values will be taken as ASCII values and converted into corresponding characters. Then the characters will be assigned to the String object.
- String(byte[ ] b, int startindex, int count) - Initialises the String object from the byte array b starting from the startindex and length be the count.
No comments:
Post a Comment