June 2002
Beginner to intermediate
640 pages
14h 24m
English
Let's see some examples of using arrays to get values from and pass values to Java methods. We'll use three methods of the Java String class (from the java.lang package): valueOf(), getBytes(), and getChar(), which are described in Table 11-6.
Since the valueOf() method takes char[] as an argument, we need to create an array of primitive type char. In Java the [] notation denotes an array.
| Method | Description |
|---|---|
| static String valueOf(char[] data) | Converts an array of primitive type char into a string |
| byte[] getBytes() | Returns the byte data associated with a string |
| void getChars(int srcBegin, int srcEnd, char [] dst, int dstBegin) | Copies characters from the string into a char array ... |
Read now
Unlock full access