A string is a collection of characters and consider as a single data item. We can represent the string by following character array:
char name[ ] = new char[9];
name[0]=’J’;
name[1]=’a’;
name[2]=’l’;
name[3]=’a’;
name[4]=’n’;
name[5]=’d’;
name[6]=’h’;
name[7]=’a’;
name[8]=’r’;
Implementing strings in java is more efficient and reliable than c. Because as you can see in the above example we have used exactly 9 characters for the word which having 9 characters but in c language a null terminated must be at the end of string, string will becomes of 10 character in c language.
There are two classes are used to implemented string in java these are as follows: