The java.lang.reflect.Array.getChar() is an inbuilt method in Java and is used to return the element present at a given index from the specified Array as a char.
Array.getChar(Object array,int index)
- array : The object array whose index is to be returned.
- index : The particular index of the given array. The element at ‘index’ in the given array is returned.
Return Type: This method returns the element of the array as char.
Note: Typecast isn’t necessary as the return type is char
Exception: This method throws following exception
- NullPointerException – when the array is null.
- IllegalArgumentException – when the given object array is not an Array.
- ArrayIndexOutOfBoundsException – if the given index is not in the range of the size of the array.
Below programs illustrate the getChar() method of Array Class:
Exception : java.lang.ArrayIndexOutOfBoundsException
Exception : java.lang.NullPointerException
Exception : java.lang.IllegalArgumentException: Argument is not an array
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- ByteBuffer getChar() method in Java with Examples
- Field getChar() method in Java with Examples
- Java.util.Collections.rotate() Method in Java with Examples
- Java.util.Collections.disjoint() Method in java with Examples
- Java.lang.string.replace() method in Java
- Java.util.ArrayList.add() Method in Java
- Java.util.ArrayList.addall() method in Java
- Java 8 | ArrayDeque removeIf() method in Java with Examples
- Java lang.Long.lowestOneBit() method in Java with Examples
- Java lang.Long.numberOfTrailingZeros() method in Java with Examples
- Java lang.Long.numberOfLeadingZeros() method in Java with Examples
- Java lang.Long.highestOneBit() method in Java with Examples
- Java lang.Long.byteValue() method in Java with Examples
- Java lang.Long.reverse() method in Java with Examples
- Java lang.Long.builtcount() method in Java with Examples
- Java.math.BigInteger.modInverse() method in Java
- Java.math.BigInteger.probablePrime() method in Java
- Java Clock tickMinutes() method in Java with Examples
- Java Clock withZone() method in Java with Examples
- Java.lang.Short toString() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : ManasChhabra2