String charAt() Method
The Java String charAt() method retrieves and returns the character at the specified position within a String. In Java, strings are indexed starting from zero, and the valid index range spans from 0 to length() - 1, where length() represents the total number of characters in the string. By utilizing the charAt() method, developers can access and manipulate individual characters within a string by referencing their corresponding index positions.
Syntax:It is important to note that, it will thrown an IndexOutOfBoundsException if the index is less than zero or greater than equal to the length of the string (index<0 index>=length()).
String Change to Uppercase
String toUpperCase()
The Java String toUpperCase() method allows for the conversion of a string to its uppercase form without the need to create a new variable to store the result. By invoking this method on a string object, the original string is transformed to uppercase characters, while the resulting uppercase string is returned. This provides a convenient and efficient way to modify the case of a string directly without the necessity of extra variable assignments.
ExampleString Change to Lowecase
String toLowerCase()
The Java String toLowerCase() method facilitates the conversion of a string to its lowercase form without requiring the creation of a new variable to hold the result. When invoked on a string object, this method modifies the original string by transforming its characters to lowercase, and subsequently returns the resulting lowercase string. This functionality allows for the direct modification of a string's case without the need for additional variable assignments, providing a convenient and efficient approach.
ExampleConclusion
The charAt() method in Java is used to retrieve the character at a specific index within a string. It returns the character value at the given position, allowing easy access to individual characters in a string by their index.