we simply sovle the problem like int count =s.replaceAll("[^a]","").length();
@ayushpandeyg2 жыл бұрын
That's professional 👍👍
@j_j8758 Жыл бұрын
Wowww that was good!
@Himu421 Жыл бұрын
Amazing video sir ! You code in such simple way and explain it so well that any basic /intermediate base person can fully grasp the concept and learn coding.
@sdetpavan Жыл бұрын
Thanks
@nayabshaik2282 Жыл бұрын
I was very scary to make understand coding earlier. But once I started watching your videos, my thought process changed. I am very comfortable to understand your logics, I feel like "OH CODING IS SUCH SIMPLE" 😄🤣 Great Thank you Pavan sir..🤝🤝🙏🙏
@CareerHirings Жыл бұрын
why writing this much complex...i dont know............ we can write in this way too String s="yash is a good boy "; char comp='a'; int flag=0; for(int i=0;i
@akadeadahot70674 жыл бұрын
this method is also easy check it guys' String str="java programming is very easy"; int count=0; for(int i=0;i
@janetbawuah89814 жыл бұрын
thanks it worked.
@udaybenake2063 жыл бұрын
This is working but does not count uppercase characters if we are pass lowercase or vice versa
@TheCrazyRitik2 жыл бұрын
@@udaybenake206 because java is case sensitive A and a both are different
@f.a5148 Жыл бұрын
@@udaybenake206 use this for Upper case or lower case: if(str.charAt(i)=='a' || str.charAt(i) == 'A')
@f.a5148 Жыл бұрын
thanks man this is much easier.
@AaminaSadiya-v5e10 ай бұрын
Superb easy to understand sir...thanks a lot for helping us.
@sdetpavan10 ай бұрын
Welcome
@Canada19893 жыл бұрын
This was asked in my interview
@Nmx74282 жыл бұрын
This is asked in my interview too with 5year experience
@Shreenidhi11010 ай бұрын
Thank you so much,very easy way to understand
@sdetpavan10 ай бұрын
Welcome
@pakkaandhrapori37684 жыл бұрын
Thanks for easy explanation and can we do the same program without "replace" method? please explain the approach as well
@bharathkoneru40084 жыл бұрын
We can do it by converting the given String to character array and then search for element. Increment the count when the element is found.
@suprem3g4mer63 жыл бұрын
@@bharathkoneru4008 how
@emmadivamshi1798 Жыл бұрын
Sir Your explanation is very nice and am very thankful to you sir
@sdetpavan Жыл бұрын
It's my pleasure
@rameshtirneddi56242 жыл бұрын
if we get string from the user then how to get max occuring character
@abinayabala68684 жыл бұрын
can u tell me how to check for all the character occurence
@swayamprakashbhuyan25803 жыл бұрын
Love your videos and commenting for better reach. You have a great voice btw.
@sdetpavan2 жыл бұрын
Thanks
@vikramsinghyadav7793 Жыл бұрын
Sir we can use Hashmap that would be more efficient
@tejajami672911 ай бұрын
import java.util.Arrays; class OccrenceOfInputArray { public static void main(String[] args) { int arr[] = {1, 1, 2, 2, 3, 4, 5, 6, 8, 9}; int len = arr.length; System.out.println("Total length: " + len); String arrString = Arrays.toString(arr); // Replace '2' with an empty string and get the length int totalCount = len - arrString.replace("2", "").length(); System.out.println("Total count of 2: " + totalCount); } } sir, while im running this program after removing the 2 we got the output is 8, but here output is getting is: -18..........please clarify this doubt sir
@hemrajpatil7823 жыл бұрын
very easy sir.thank u. sir can u please make programm for prime no. from array ..please sir .
@SaisowmyaPriya Жыл бұрын
hi sir can we use this method is scanner sirif yes can u tell me how to use it
@v2factsand327 Жыл бұрын
Excellent explanation
@sdetpavan Жыл бұрын
Glad it was helpful!
@rizwanreshi8673 Жыл бұрын
Sir what about when there are same letter with upper and lower case.
@vladshome Жыл бұрын
you can use the ".toLowerCase()" method on the string, before removing the character you're counting. it will make the whole String lowercase
3 жыл бұрын
Tell for all character occurences. For all occurences it will become a very exhausting code
@vithvishnu14974 жыл бұрын
Can i get this in loop.. if yes can u comment the statement..
@udaybenake2063 жыл бұрын
This is working but does not count uppercase characters if we are pass lowercase or vice versa
@rohanmane74232 жыл бұрын
Do s=s.toLowerCase(); /toUpperCase();
@MB-zt7cd4 жыл бұрын
Nice explanation however I am bit confused, as we count the spaces as well in index., So when we are replacing a with space, the space would still be counted. so not sure how did it work. Could you please explain the logic for that. Thank you
@avinashhr4 жыл бұрын
He is not replacing with space its null.
@bharathkoneru40084 жыл бұрын
Its not replacing with space, a is replaced with empty(""). space means " " empty means ""
@pawan_2883 ай бұрын
good
@osaimurari3485Ай бұрын
burra padu sir!
@gayathridhana1000 Жыл бұрын
sir please make more interview programs
@NiteshKumar-vz8uy Жыл бұрын
This question asked me today
@ravindrakawale51612 жыл бұрын
Great explain....🙌🙌
@sdetpavan2 жыл бұрын
Glad it was helpful!
@vs40843 жыл бұрын
Thankyou sir for this video...
@sdetpavan2 жыл бұрын
Most welcome
@shraddhaprabhu9033 Жыл бұрын
Sir make program video of duplicate characters in a string
@zishanalam82772 жыл бұрын
What about no case sensitive
@krishdeepika6967 Жыл бұрын
Not working giving output as zero
@kvnagendra53544 жыл бұрын
Nice explanation
@sdetpavan Жыл бұрын
Thanks
@magicalmagie28892 жыл бұрын
Sir y u removing a es
@groundlevel18172 жыл бұрын
impressive.
@sdetpavan2 жыл бұрын
thanks
@ananya867211 ай бұрын
not a good approach
@iliveinacrowdedhouse3684 жыл бұрын
Bonne vidéo
@bidya742 жыл бұрын
corrupted
@kvelez Жыл бұрын
import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { System.out.print(" Enter a statement: "); Scanner scan = new Scanner(System.in); String statement = scan.nextLine(); scan.close(); String[] words = statement.split("\\s+"); HashMap wordHashMap = new HashMap(); HashMap letterHashMap = new HashMap(); for (int i = 0; i < statement.length(); i++){ char currentChar = statement.charAt(i); if (letterHashMap.containsKey(currentChar)){ letterHashMap.put(currentChar, letterHashMap.get(currentChar) + 1); } else { letterHashMap.put(currentChar, 1); } } for (Character letter : letterHashMap.keySet()){ int count = letterHashMap.get(letter); System.out.println("Letter: " + letter + " appears " + count + " times."); } for (String word : words){ if (wordHashMap.containsKey(word)){ wordHashMap.put(word, wordHashMap.get(word) + 1); } else { wordHashMap.put(word, 1); } } for (String item : wordHashMap.keySet()){ int count = wordHashMap.get(item); System.out.println("Word: " + item + " appears: " + count + " times."); } } }
@MAGAVISHNUT2 жыл бұрын
This for known statement.. Then what is code for when we use scanner Class