You are on page 1of 2

PROFESSIONAL COMPUTERS JAGATPURA JAIPUR

String Extraction functions


charAt(int index) char c=s1.chatAt(index) toCharArray() Ex. Char a[]=s1.toCharArray() S1.substring(n,m) S1.indexof(x) S1.concat(s2) S2=s1.replace(X,Y) S2=s1.toLowerCase S2=s1.toUpperCase Return the char value at the specified index. Index range from 0 to length()-1 Convert the invoking string s1 to a new character array. Gives substring from nth character Gives the position of the first occurrence of x character in the string s1 Concatenates s1 and s2 Replace all the appearance of X char with Y char and store it string s2. Convert the s1 to lowercase and assign to s2 Convert the s1 to uppercase and assign to s2 Return true if s1 string is equal to s2 Return negative if s1<s2,positive if s1>s2, otherwise 0 Same as compareTo but it ignore the difference between small and capital character Same as equals method but it ignore the case. Convert string to double type Convert string to Float type Convert string to int type Convert string to long type Convert int i to string type Convert float f to string type Convert double d to string type

String Comparison method


S1.equlas(s2) S1.compareTo(s2) S1.compareToIgnoreCase(s2) S1.equalsIgnoreCase(s2) Double val=Double.ValueOf(str) float val-Float.ValueOf(str) int val=Integer.ValueOf(str) long val=long.ValueOf(str) Str=Integer.toString(i) Str=Float.toString(f) Str=Double.toString(d)

Converting String objects to Numeric Object

Converting Neumeric objects to String Object

StringBuffer methods There is not method to delete a character from string.


StringBuffer append( char c ) StringBuffer append( int i ) StringBuffer append( long L ) StringBuffer append( float f ) StringBuffer append( double d ) StringBuffer append( String s ) int capacity() append c to the end of the StringBuffer convert i to characters, then append them to the end of the StringBuffer convert L to characters, then append them to the end of the StringBuffer convert f to characters, then append them to the end of the StringBuffer convert d to characters, then append them to the end of the StringBuffer append the characters in s to the end of the StringBuffer return the current capacity (capacity will grow as needed).

PROFESSIONAL COMPUTERS JAGATPURA JAIPUR


char charAt( int index ) StringBuffer insert( int index, char c) StringBuffer insert( int index, String st) StringBuffer insert( int index, int i) StringBuffer insert( int index, long L) int length() StringBuffer reverse() void setCharAt( int index, char c) String toString() get the character at index. insert character c at index (old characters move over to make room). insert characters from st starting at position i. Convert i to characters, then insert them starting at index. Convert L to characters, then insert them starting at index. return the number of characters. Reverse the order of the characters. set the character at index to c. Return a String object containing the characters in the StringBuffer. Inserts the specified element at the specified position in this Vector. Adds the specified component to the end of this vector, increasing its size by one. Removes all of the elements from this Vector. Copies the components of this vector into the specified array. Returns the component at the specified index. Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method. Removes the element at the specified position in this Vector.

Vector in /java
add(int index, Object element) addElement(Object obj) clear() copyInto(Object[] anArray) elementAt(int index) insertElementAt(Object obj, int index) remove(int index)

You might also like