index

Ads

 
 

Share on Google+Share on Google+

remi
index
1 Answer(s)      8 years ago
Posted in : Java Beginners
Ads
View Answers

August 10, 2009 at 4:40 PM


Hi Friend,

Try the following code:

import java.io.*;
import java.awt.*;
import java.util.*;
import javax.swing.*;

class CountCharacters {
public static void main(String[] args) throws Exception{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Please enter string ");
System.out.println();
String str=br.readLine();
String st=str.replaceAll(" ", "");

char[]third =st.toCharArray();
for(int counter =0;counter<third.length;counter++){
char ch= third[counter];
int count=0;
for ( int i=0; i<third.length; i++){
if (ch==third[i])
count++;
}
boolean flag=false;
for(int j=counter-1;j>=0;j--){
if(ch==third[j])
flag=true;
}
if(!flag){
System.out.println("Character :"+ch+" occurs "+count+" times ");
}
}
}
}

Hope that it will be helpful for you.
Thanks

Ads









Related Tutorials/Questions & Answers:
What is Index?
What is Index?  What is Index
Advertisements
index of javaprogram
index of javaprogram  what is the step of learning java. i am not asking syllabus am i am asking the step of program to teach a pesonal student.   To learn java, please visit the following link: Java Tutorial
Drop Index
Drop Index       Drop Index is used to remove one or more indexes from the current database. Understand with Example The Tutorial illustrate an example from Drop Index
clustered and a non-clustered index?
clustered and a non-clustered index?  What is the difference between clustered and a non-clustered index
Mysql Btree Index
Mysql Btree Index  Mysql BTree Index Which tree is implemented to btree index? (Binary tree or Bplus tree or Bminus tree
z-index always on top
z-index always on top  Hi, How to make my div always on top using the z-index property? Thanks   Hi, You can use the following code: .mydiv { z-index:9999; } Thanks
array, index, string
array, index, string  how can i make dictionary using array...please help
NSMutableArray change object at Index
NSMutableArray change object at Index   NSMutableArray change object at Index   // Browse all messages (you can use "for (NSDictionary *message in allMessageArray)" enumerate loop but because we need the index
$_GET[] index is not defined
$_GET[] index is not defined  Hi, What could be solution of the error: $_GET['someparameter'] index is not defined Thanks   Hi, You can use the following code: if (isset($_GET['someparameter'])) { // your code
Version of com.thesett>index dependency
List of Version of com.thesett>index dependency
checking index in prepared statement
checking index in prepared statement  If we write as follows: String query = "insert into st_details values(?,?,?)"; PreparedStatement ps = con.prepareStatement(query); then after query has been prepared, can we check the index
JavaScript array index of
JavaScript array index of  In this Tutorial we want to describe that makes you to easy to understand JavaScript array index of. We are using JavaScript... line. 1)index of( )  - This return the position of the value that is hold
alter table create index mysql
alter table create index mysql  Hi, What is the query for altering table and adding index on a table field? Thanks
Drop Index
Drop Index       Drop Index is used to remove one or more indexes from the current database... Index. In this example, we create a table Stu_Table. The create table is used
alter table create index mysql
alter table create index mysql  Hi, What is the query for altering table and adding index on a table field? Thanks   Hi, Query is: ALTER TABLE account ADD INDEX (accounttype); Thanks
Java arraylist index() Function
Java arrayList has index for each added element. This index starts from 0. arrayList values can be retrieved by the get(index) method. Example of Java Arraylist Index() Function import
creating index for xml files - XML
creating index for xml files  I would like to create an index file... after another and then retrieve each tag and create index to that file. In some cases, more than one file may have same name. So, my index file would be like
Mysql Date Index
Mysql Date Index       Mysql Date Index is used to create a index on specified table. Indexes... combination of columns in a database table. An Index is a database structure which
Maven Dependency index >> 0.9.65
You should include the dependency code given in this page to add Maven Dependency of com.thesett >> index version0.9.65 in your project
Maven Dependency index >> 0.8.1
You should include the dependency code given in this page to add Maven Dependency of com.thesett >> index version0.8.1 in your project
Maven Dependency index >> 0.8.20
You should include the dependency code given in this page to add Maven Dependency of com.thesett >> index version0.8.20 in your project
Maven Dependency index >> 0.8.18
You should include the dependency code given in this page to add Maven Dependency of com.thesett >> index version0.8.18 in your project
Maven Dependency index >> 0.8.12
You should include the dependency code given in this page to add Maven Dependency of com.thesett >> index version0.8.12 in your project
Maven Dependency index >> 0.8.15
You should include the dependency code given in this page to add Maven Dependency of com.thesett >> index version0.8.15 in your project
Maven Dependency index >> 0.8-M1
You should include the dependency code given in this page to add Maven Dependency of com.thesett >> index version0.8-M1 in your project
Maven Dependency index >> 0.8.6
You should include the dependency code given in this page to add Maven Dependency of com.thesett >> index version0.8.6 in your project
Maven Dependency index >> 0.9.86
You should include the dependency code given in this page to add Maven Dependency of com.thesett >> index version0.9.86 in your project
Maven Dependency index >> 0.8.2
You should include the dependency code given in this page to add Maven Dependency of com.thesett >> index version0.8.2 in your project
Maven Dependency index >> 0.8.8
You should include the dependency code given in this page to add Maven Dependency of com.thesett >> index version0.8.8 in your project
Maven Dependency index >> 0.8.11
You should include the dependency code given in this page to add Maven Dependency of com.thesett >> index version0.8.11 in your project

Ads

 
Advertisement null

Ads