Sunday, January 27, 2019

Java Program 1: How to read characters of a String?

String is a character sequence enclosed in double quotes. We can't access its characters one by one like we access the values of an array (a[0], a[1] and etc.) directly.

But we can do it in java in different ways, we will see two approaches in this post.

Method 1: Using CharAt(int i) method

Execute above program and observe below output screenshot, we can see that using CharAt() method we are able to get each character from the given string.


Method 2: Using toCharArray() method

Execute the above program and observe below output screenshot, we have converted the given String first to a Character Array and read the characters one by one using for loop.


#HappyLearning #HappyTesting

2 comments:

Katalon 08: Integration of HP ALM with Katalon Studio

In this post, this post we discuss about integration of  HP ALM with Katalon Studio. If we can integrate HP ALM with Katalon we can update ...