Java Interview Question: How To Count Occurrences Of Each Character In String In Java

preview_player
Показать описание
In this video, I have explained one famous Java Interview Question: How To Count Occurrences Of Each Character In String In Java

~~~Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:

Follow me on my Facebook Page:

Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:

Naveen AutomationLabs Paid Courses:
Java & Selenium:

Java & API +POSTMAN + RestAssured + HttpClient:
Рекомендации по теме
Комментарии
Автор

All my interest in Java is because of you. I can't thank you enough for all that you have done for us!! 👏

sanghamitrabhowmicklive
Автор

Thanks Naveen for the video . For the assessment we just have to remove not symbol from if(String.valueOf(c).is blank()).

praveen
Автор

Your approach is really so easy to understand and you solve the program in most efficient way too
Thank you so much...

surabhibn
Автор

Thankyou sir the way you explained awesome..it's makes every one to easy understand...
For only spaces count we use instead of not if condition

shashikumarkondoju
Автор

Thank you souch for sharing this Naveen, this is mandatory question asked in many interviews for experienced candidates

lavanya.ds
Автор

Thanks for the explanation Naveen. It's because of you, yesterday I cracked one more interview!

antarabanerjee
Автор

solution for counting space
int count=0;
for(char ch:name.toCharArray()) {
if(ch==' ') {
count++;
}
}

System.out.println(count);

anilds
Автор

Hi NAVEEN,
Good day!

The same program I was facing in the technical round and I wrote and explained to the interviewer. I cracked and cleared the first round as well. Thank you, please post more mock interviews. Thanks a lot..

NagarajuN-evpl
Автор

For checking space, replace "a" with space : String str = "this is a java programming";
int result = str.length()- str.replaceAll("a", "").length();
System.out.println(result);

cngramesh
Автор

YOU'RE THE MAN!!, THANK but why u had to test ur code for 10 min lol

thatsdeep
Автор

Solution for only space we need to take count of string and replaceall method
int ", "").length();

System.out.println(n);

anilds
Автор

most of the interview this question asked ...if not this then ...some what similar to this problem.

ashuiet
Автор

Thank you so much for the amazing videos on Java concepts Naveen. it really helps in improving my coding skills. Could you also please make a video on how to print all the permutations of a given string "abc" (like acb, bca, cab, cba..etc., ). (It was asked in the interview with ADP company). There are many logics present on the internet but not fully understandable, just wanted to get it from you which obviously would be easy to understand and implement.

khajazakiuddin
Автор

To count only spaces, we will remove NOT from condition like below

ParamjitKaur-josz
Автор

Print occurences of each word and character in a string : it was asked in the interview

Wandereatstravel
Автор

Yes sir, by just removing the (!) In the
we got only spaces

programminghubbharat
Автор

This program is case sensitive
the uppercase and lowercase occurences of same letters are counted seperately.

aparna
Автор

I am well versed in Python, Should I learn Java as well?

MrAshu
Автор

Make a video for String Builder and String Buffer bro.

lathaa
Автор

sir. thanks for the video .can we do this in java 8

devanandthirunavukkarasu
welcome to shbcf.ru