-->
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Saturday, August 12, 2017

String Class

Java provides some inbuilt classes to manipulate strings.One of them is java.lang.String.This class provides a lot of methods for string manipulation. The java.lang.String implements 
i)Serializable
ii)Comparable<String>
iii)CharSequence interfaces

Creating String with String class

String name="Hello"
String name=new String("Java");


String class Methods:

Methods

Description

char charAt() returns the character at 'index'
int length() returns the length of String
int compareTo(String anotherString) Compares two strings lexicographically
int compareToIgnoreCase(String str) Compares two strings lexicographically, ignoring case differences.
String concat(String str) Concatenates the specified string to the end of this string.
boolean contains(CharSequence s) Returns true if and only if this string contains the specified sequence of char values.
boolean contentEquals(CharSequence cs) Compares this string to the specified CharSequence
boolean equals(Object anObject) Compares this string to the specified object
boolean equalsIgnoreCase(String anotherString) Compares this String to another String, ignoring case considerations
void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) Copies characters from this string into the destination character array.
int hashCode() Returns the index within this string of the first occurrence of the specified character.
int indexOf(int ch) Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index
int indexOf(int ch, int fromIndex) Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.

No comments:

Post a Comment