Java The Complete Reference, Seventh Edition
boolean regionMatches(booleanignoreCase, intstartIndex, Stringstr2, intstr2StartIndex, intnumChars) For both versions,startIndex ...
Chapter 15: String Handling 367 public static void main(String args[]) { String s1 = "Hello"; String s2 = new String(s1); System ...
368 Part II: The Java Library arr[j] = arr[i]; arr[i] = t; } } System.out.println(arr[j]); } } } The output of this program is t ...
Chapter 15: String Handling 369 To search for the first occurrence of a character, use int indexOf(intch) To search for the last ...
370 Part II: The Java Library Here is the output of this program: Now is the time for all good men to come to the aid of their c ...
Chapter 15: String Handling 371 result = result + sub; result = result + org.substring(i + search.length()); org = result; } } w ...
trim( ) Thetrim( )method returns a copy of the invoking string from which any leading and trailing whitespace has been removed. ...
type can be converted properly into a string.valueOf( )is also overloaded for typeObject, so an object of any class type you cre ...
374 Part II: The Java Library String upper = s.toUpperCase(); String lower = s.toLowerCase(); System.out.println("Uppercase: " + ...
Method Description String[ ] split(StringregExp) Decomposes the invoking string into par ts and returns an array that contains t ...
length( ) and capacity( ) The current length of aStringBuffercan be found via thelength( )method, while the total allocated capa ...
Chapter 15: String Handling 377 When you increase the size of the buffer, null characters are added to the end of the existing b ...
contains the characters fromsourceStartthroughsourceEnd–1. The array that will receive the characters is specified bytarget.The ...
Chapter 15: String Handling 379 insert( ) Theinsert( )method inserts one string into another. It is overloaded to accept values ...
380 Part II: The Java Library delete( ) and deleteCharAt( ) You can delete characters within aStringBufferby using the methodsde ...
sb.replace(5, 7, "was"); System.out.println("After replace: " + sb); } } Here is the output: After replace: This was a test. sub ...
Method Description int offsetByCodePoints(intstar t, intnum) Returns the index with the invoking string that isnumcode points be ...
16 Exploring java.lang 16 Exploring java.lang T his chapter discusses thos e classes and interfaces defined byjava.lang. As you ...
Primitive Type Wrappers As mentioned in Part I of this book, Java uses primitive types, such asintandchar, for performance reaso ...
The methods defined byFloatare shown in Table 16-1. The methods defined byDouble are shown in Table 16-2. BothFloatandDoubledefi ...
«
16
17
18
19
20
21
22
23
24
25
»
Free download pdf