19 - Java Program to count total number of characters in a string
Вставка
- Опубліковано 8 вер 2024
- Here is the link of Full Play List ► bit.ly/2ZGeBFC
Here we will learn a Java Program to count total number of characters in a string.
Additional Info
Link for SDET/QA Interview Full Play List ► bit.ly/3frBpQZ
Link for API Testing Full Play List ► bit.ly/2BY0vHu
Link for Cypress Tutorial Full Play List ► bit.ly/3iMdi2a
Link for Web-services Full Play List ► bit.ly/3bfK0Ef
Link for Protractor Testing Full Play List ► bit.ly/2ztlEIK
Link for Java Programs for Software Testers Full Play List ► bit.ly/2ZGeBFC
Link for Java Tutorial Full Play List ► bit.ly/2Z3tP8L
Link for Selenium Tutorial Full Play List ► bit.ly/3vFR9X5
Link for TestNG Full Play List ► bit.ly/3jGJ3YT
Please subscribe to our channel ► bit.ly/2UIvFcm
and press the bell icon to get updates on latest tutorial.
Thanks brother it helped me a lot
Glad to hear that
Great
Thank you 😊
Put the video for print and count how many common characters in two strings
10th line
getting error in 10 in my eclipse
Here is the complete code, Let me know if u need any more help.
public class CountCharactersInaString {
public static void main(String[] args) {
String s = "Learn Java today";
int count = 0;
System.out.println("Length of the string is " + s.length());
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) != ' ') {
count++;
}
}
System.out.println("Count of characters " + count);
}
}
Why so much line of code just use length function u will get it
It will count space also...but space is not character
it showing error.
Where You are getting error ?
Here is the complete code, Let me know if u need any more help.
public class CountCharactersInaString {
public static void main(String[] args) {
String s = "Learn Java today";
int count = 0;
System.out.println("Length of the string is " + s.length());
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) != ' ') {
count++;
}
}
System.out.println("Count of characters " + count);
}
}
@@SoftwareTestingAndAutomation thanku. now working fine.