Contents :
A set of Characters enclosed within double quotes (i.e. " ") is known as string.
[Note the default initial value of string is ""].
Assigning of a String variable:
Direct assignment:
Syntax: String variable = "____";
Eg- String str1 = "Good evening !!";
Assignment by using new keyword:
Syntax: String variable = new String( );
Eg- String str2 = new String("Good afternoon !!");
int length()
This function tells the number of characters present in a string. [Note: Space is also counted as a char by the computer].
char charAt(int index)
This function tells the character present on the position entered by the user. [Note: The count starts from 0, i.e. the first char is assigned the position of 0 and then it proceeds as normal]
int indexOf(char c)
This function tells the first position of the character entered in the string.
A modification of this can be to add a position after which the computer will start searching for the char.
int lestIndexOf(char c)
This function tells in which position the specific character appears the last time in a String.
String substring(int startindex)
This function creates another string which is derived from the main string. The int entered tell after which position the sub string starts.
A modification of this can be adding a end position. i.e. start position tells from which position the substring starts and ends at which position. [For your information, in the example the length of the string is 13 (As First position is taken as 0)].
String toLowerCase()
This function converts all the letters in a string to lower case irrespective of the case the char is in.
String toUpperCase()
This function converts all the letters in a string to upper case irrespective of the case the char is in.
String replace(char to_replace, char replacement)
This function replaces the specific character with what you want as replacement of it. (Good for writing Secret messages to each other)
String replace( to_replace_setofcharacters, replacement_setofcharacters)
This function replaces the specific set of character (a sub-string) with the other set of characters (another sub-string).
String concat(String str)
This function joins two or more strings into one big string.
But, we can also make use of the '+' operator to join two strings, instead of using this concat.
boolean equals(String str)
This function checks weather the two strings are equal or not [Note: You cant use '==' operator to check if the two strings are equal are not, as it can only be used for primitive data types && also it is case sensitive].
boolean equalsIgnoresCase(String str)
This function checks weather the two strings are equal or not ignoring the case of the characters.
boolean startsWith(String str)
This function checks weather the string starts with another string.
boolean endsWith(String str)
This function checks weather the string ends with another string.
String valueOf(primative_data_type)
This function converts a primitive data type variable into a string.
primitive_datatype valueOf(String str)
This function converts a numeric (Containing only numbers) string into a string.