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
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
You shares a lot of useful information about technology. Thank you for sharing this with us and keep sharing more like this.
ReplyDeleteC++ Training in Chennai
C C++ Training in Chennai
core java training in chennai
javascript training institute in chennai
javascript training in chennai
core java training in chennai
core java training
Great Article
Deleteandroid based projects
Java Training in Chennai
FInal Year Project Centers in Chennai
Java Training in Chennai
projects for cse
The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training
Awesome information.
ReplyDeletesuch an useful article.
thanks for posting.keep sharing.
Best java training in Bengaluru