Skip to content

Automation Testing

Java, Selenium etc..

  • Java
  • Selenium
  • Interview Question
  • Core Java Coding
  • Rest APIS
  • Manual Testing
  • SQL Queries
  • Postman
  • Toggle search form

Tag: Java program to count the occurrence of each character in a string using Hashmap

String Char Counts Using Collections

Posted on May 10, 2023May 10, 2023 By admin

String Char Counts Using Collections: package InterViewQuestions;import java.util.HashMap;import java.util.Map;public class StringCharCountsUsingCollections { //string = hemchandrraBhatt //print number chars repeated public static void main(String[] args) { String str = “hemchandrabhatt”; HashMap<Character, Integer> mapCharCount = new HashMap<>(); char[] charArr = str.toCharArray(); for (char c : charArr) { if (mapCharCount.containsKey(c)) { mapCharCount.put(c, mapCharCount.get(c) + 1); } else {…

Read More “String Char Counts Using Collections” »

Core Java Coding Questions

Recent Posts

  • Can you write java program for prime number 1to 50 and skip printing 30 and 40 numbers
  • Java 8 features
  • Imp Links
  • Create a Java program to store the Name and Salary of employees
  • String Char Counts Using Collections

Recent Comments

No comments to show.

Copyright © 2022 okhalaTech