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...

Hi,

This is ravi i have a question like this i have string
"UNDERSTAND" now i want to count the letters how many times
it occures.i.e from the above string the out put should be
like this U-1,N-2,D-2,E-1,R-1,S-1,T-1,A-1.
how can i achieve this

Thnaks in advance for your response ..

Answer Posted / pradeep mishra

public class CountOccur {
String str="ANAND";
int c1=0;
int c2=0;
int c3=0;
String retun=null;

public static void main(String[] args) {
CountOccur co=new CountOccur();
System.out.println("Ocurrence "+co.Test());
}

public String Test() {
for( int i=0;i<str.length();i++){
if(str.charAt(i)=='A')
c1++;
if(str.charAt(i)=='N')
c2++;
if(str.charAt(i)=='D')
c3++;
}
retun="A"+c1+"N"+c2+"D"+c3;
return retun;
}
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the purpose of the System class?

949


What happens to the Exception object after handling an exception?

2322


I am a fresher and know core java, c languge, html, css etc if I am illegible for any job then send it on my email tatranakshay276@gmail.com

1635


How to sort double array in java?

941


Explain the difference between static and dynamic binding in java?

1016


What is generic type?

976


What are the types of collections in java?

1000


Why does java not support pointers?

1007


What is java string pool?

946


What is java util list?

875


For ease of programming you can consider the maze as a 2D array with colors represented by below integer and characters (in capital letters). • B - Black • W -White • G- Green • R- Red R B W B W W W W W W B W B B W W W W W W W B W B W W W B W W W W B B W W W B W W W B W W B B B B W B W B W W B W W W B W W W B B B W W B W W W B W W B W B W W W B W B W W W W B B W W W W B W W W W W G Shortest Route Problem: • Solution that finds the shortest Route between Red and Green  White will have 1 Weight.  Red and Green carry no weights.  Shortest path is the path with less weight when you add up the weights in the path.

1970


What is variable explain?

954


What is the collections api?

985


How can we make a class virtual?

1059


Can a abstract class be declared final?

944