Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

A string of charaters were given. Find the highest
occurance of a character and display that character.
eg.: INPUT: AEGBCNAVNEETGUPTAEDAGPE

Answer Posted / arpita

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

public class TestClass1 {
public static void main(String[] args) {
HashMap<Character, Integer> hm = new HashMap<Character,
Integer>();
String str = "AABBBCCZX";
if (str != null) {
char[] charArray = str.toCharArray();
for (char ch : charArray) {
int counter = 0;
for (int j = 0; j < charArray.length; j++) {
if (ch == charArray[j]) {
counter = counter + 1;
}
}
hm.put(ch, counter);
}

Set<Character> s = hm.keySet();
Iterator<Character> itr = s.iterator();
while (itr.hasNext()) {
char key = (char) itr.next();
System.out.println("Character : " + key + " Occurence : "
+ hm.get(key));
}
}

}
}

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

in IBM PC -AT.WAT AT REFERS TO?

1962


what is the diff bw sql direct and jdbc update can't we do select and updating operation in sql direct

2217


write a sql qwery which include joining of two tables 4 marks mainframe

1993


can we use commit,rollback in triggers and how?

2037


What is easiest way to get the PL/i compiler,I didn't have found the compiler in my library. Is there any extra cost if we want to access the PL/1 programs?Actually we r having Mainframe rented training Ids

2303


10.Define filters,binary to hexadecimal,hexadecimal to decimal?

2207


how do we provide security for web services

2403


3 members in a pf.how we read 3 members without using ovrdbf.using rg pgms....

2324


what is session state?

2022


Outline the two important features of a terminating recursion. Any ideas?

2272


define profiler???

2099


What are the Short cut Keys of Tally ERP?

2394


In loading programs into memory, what is the difference between load-time dynamic linking and run-time dynamic linking?

2263


what are the things i had to say in personal introduction in hr round mail me to prasanna.1867@rediff.com

2176


How can recruiter justified that the candidate is expert in Algorithm and datastructure for Software product development ?

2007