Тэги:
#How_To_Count_Occurrences_Of_Each_Character_In_String_In_Java #occurrence_of_character_in_string_in_java #occurrence_of_character_in_string_in_python #occurrence_of_character_in_string_in_c #count_char_in_string_java #string_char_count_c# #get_the_occurrence_of_each_char #tricky_java #tricky_javascript_interview_questions #tricky_java_interview_questions #tricky_java_coding_questions #java_interview_questions_for_selenium_testers #java_interview_questions_for_experiencedКомментарии:
All my interest in Java is because of you. I can't thank you enough for all that you have done for us!! 👏
ОтветитьThe people who getting error in isBlank method they can use in that if statement like below
if(c!=' '){
}
solution for counting space
int count=0;
for(char ch:name.toCharArray()) {
if(ch==' ') {
count++;
}
}
System.out.println("******************");
System.out.println(count);
Solution for only space we need to take count of string and replaceall method
int n=name.length()-name.replaceAll(" ", "").length();
System.out.println("spaceCount");
System.out.println(n);
Sir, how can i get output as te2s3h if input is teesssh with stream ??
Ответитьsir ap hindi main bnao yr video
ОтветитьYOU'RE THE MAN!!, THANK YOU!!!!!!!!!!!! but why u had to test ur code for 10 min lol
ОтветитьTo count only spaces, we will remove NOT from condition like below
if(String.valueOf(c).isBlank())
veryyy very nice explaination
Ответитьsimple remove ! in (String.valueOf(C).isBlank()){} condtion
ОтветитьBeautiful explanation
ОтветитьPrint occurences of each word and character in a string : it was asked in the interview
ОтветитьThank you Naveen!! God bless you 🙏
ОтветитьHi Naveen, I m getting error while using the isBlank() method. Error showing that method isBlank() is undefined for type string.
ОтветитьYes sir, by just removing the (!) In the
if(!string.valueof(c).isBlank()) we got only spaces
String S1="hello"
String S2="12345"
Output=h1e2l3l4o5. Can you plz write program for above output
sir. thanks for the video .can we do this in java 8
ОтветитьBetter, u can do videos for Less time
Ответить1 2 three 3 4 three 5 6 three 7 8 three.......20.anyone can solve this please aisa output aana chahiye
ОтветитьYour approach is really so easy to understand and you solve the program in most efficient way too
Thank you so much...
Hi Naveen,
Just a question..
For thr first test case i.e input "test" the output Hashmap values must be {(t,1)(e,1)(s,1)(t,2)} .. right??
Because we are just adding a new key value pair to the hashmap but we are not updating the existing key-value pairs as per this code...
For the 4th input character : 't' it will check if 't' is already present in the map. Since it is already there, it will fetch it's value which is 1 and then increments it by 1..so it will become 2 and will update a new key-value pair as( t,2) to the existing hashmap...so the final hashmap output should be {(t,1)(e,1)(s,1)(t,2)} ..
Please explain how it is giving {(e,1)(s,1)(t,2)} as output..
Thanks in advance.