Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Count the character in java
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Kaushlendra
Count the character in java
1 Answer(s)      3 years and 7 months ago
Posted in : Java Beginners


Write a java program to count the character â??aâ?? typed by the user in a paragraph by implementing thread.


Advertisement
View Answers

February 26, 2011 at 1:13 PM


Count characters by implementing thread

import java.util.*;
class  CountCharacters {
    public static void count(final String str){
    Runnable readRun1 = new Runnable() {
      public void run() {
          try{
          Thread.sleep(5000);
          String st=str.replaceAll(" ", "");
  char ch[]=st.toCharArray();
  int count=ch.length;
  System.out.println("Total Characters: "+count);
       } catch(Exception ex) {
       }  
      }
    };
    Thread thread1 = new Thread(readRun1);
    thread1.start();
    }
    public static void main(String[] args) throws Exception{
  Scanner input=new Scanner(System.in);
  System.out.print("Please enter string ");
  String str=input.nextLine();
  count(str);
    }
}


Related Tutorials/Questions & Answers:
Count the character in java
Count the character in java  Write a java program to count the character â??aâ?? typed by the user in a paragraph by implementing thread.   Count characters by implementing thread import java.util.*; class
Character count by while loop
Character count by while loop  Write the program to count the number...]) flag=true; } if(!flag){ System.out.println("Character :"+ch+" occurs "+count...]; int count=0; for ( int i=0; i<third.length; i++){ if (ch==third[i
Advertisements
J2ME count character into string
J2ME count character into string  i am new in J2ME, my problem is how to count character into number, i had been research google for almost 2 days... form which allow user to input character user input helloworld then press
count the repeated character in one string
count the repeated character in one string  to find the how character occurrence in one String (for example the string is -java means there is 2...; } if(!flag){ System.out.println("Character :"+ch+" occurs "+count+" times
Count characters from text file in Java
Count characters from text file Using Java Here we are going to count the occurrence of each character from the text file. For this, we have used... it into character array in order to count the occurrence of each character
Count Characters from the input string Java
Count Characters from the input string of Java In this section, you will learn how to count the occurrence of each character in the string. For this, we have... to count the occurrence of each character of the array.  Here is the code
count in java - Java Beginners
, count of frmale is 20. what's code in java to select count from database where...count in java  Hello javamania.... i want to ask something like... is 20. i have JFrame Form(jTextField,jLabel,jButton), i want to get count
Character Directions in java
Character Directions in java  java 2,version 1.4 adds a method "getDirectionality();" , what is the use of this method ?   This method returns the Unicode directionality property for the given character. Character
Setting the default Java character encoding?
Setting the default Java character encoding?  Setting the default Java character encoding
character counter - Java Beginners
character counter  how to show only first three characters of the entered(by user) name?  hy katy, import java.io.*; class counter...!!"); } else{ System.out.println("First Three Character is:"+c[0]+c[1]+c[2
Ask java count
Ask java count  Good morning, I have a case where there are tables... | Java 1 | 10 | | b002 | beginner java | 5 | | b003 | advanced java book | 26 | | b004 | MySQL 1
word and character counting - Java Beginners
word and character counting  here is the java code i made but i have to add something where it will read the inFile and display the number of words... javax.swing.*; import java.io.*; public class count { public static void main
letter count problem - Java Beginners
letter count problem  i have a problem in my java coding to count two characters of a string. eg to count the letter "ou" in the string "How do you feel today?". The answer should be 5. but i still have error compiling
Count characters from text file in Java
is a java code that count the occurrence of each character from text file. import...Count characters from text file in Java  At the "Count chracters fro mtext file in Java". I tried to run the code, but the error at the line have
count asterisk in a grid - Java Beginners
count asterisk in a grid  I need to write a program that uses a recursive method to count the number of asterisk in a square grid
Java program to generate the total count
Java program to generate the total count  I need a java program which would take a text file as an input and scans through it to generate the output. For Ex. : If the text file contains the following information: There is/are 3
Java count vowels
Java count vowels In this section you will learn how to count the number... and then you will get the number of vowels count. Description of code : In this code... will read the string once you enter the string. Then we have taken a count
Character from text file - Java Beginners
Character from text file  Write a program that reads characters from a text file. Your program will count how many time each character appear...: ?The contents of a string cannot be changed once the string is created.? Character
How to get the unicode of japanese character input in java
How to get the unicode of japanese character input in java  Good Evening sir/madam; I am trying to create an application in java which needs to show the japanese character on frame and need to get the japanese string from
Jsp count and java bean - JSP-Servlet
Jsp count and java bean  Please am on a project and i want to create a countdown timer that will have this format HH:MM:SS. Am working with jsp and java beans please somebody help.  Hi Friend, Try the following
count statement that saves results on a variable in a java bean
count statement that saves results on a variable in a java bean  ... = ""; ResultSet nu = null; SQLStr = "SELECT COUNT(*) AS COS FROM dev.history WHERE previous like 1; "; SQLStr = "SELECT COUNT(PREVIOUS
count statement that saves results on a variable in a java bean
count statement that saves results on a variable in a java bean  ... = ""; ResultSet nu = null; SQLStr = "SELECT COUNT(*) AS COS FROM dev.history WHERE previous like 1; "; SQLStr = "SELECT COUNT(PREVIOUS
find all unique character in string using java
find all unique character in string using java  example: hello how are you. output should be waryu
how to count words in string using java
how to count words in string using java  how to count words in string...: "); String st=input.nextLine(); int count=0...()){ String token=stk.nextToken(); count
Find number of words begin with the specified character
Count number of words begin with the specified character In this section, you... with the input character. If found, counter will count the words. Here is the code...("Enter character to count:"); String s1 = input.next(); StringTokenizer stk
Count number of occurences and print names alphabetically in Java
Count number of occurences and print names alphabetically in Java  I... for the printCount() method for the code to count the number of occurences of each...]+" "; } str = str.toLowerCase(); int count = -1
Java get middle character
Java get middle character In this tutorial, you will learn how to get middle character from the word. Here is an example of getting the middle letter of the word entered by the user using Java. If you have a word string 'company
java program to insert data into a file and count the number of words from the file???????
java program to insert data into a file and count the number of words from the file???????  java program to insert data into a file and count the number of words from the file
How to delete a character from a file in java - Java Beginners
How to delete a character from a file in java  I'm not gettting how to remove a character from a file in java....could any one help me out??  Hi friend, To remove a character in what way : At a specified position
Java count files in a directory
Java count files in a directory In this section, you will learn how to count... directory. But we have to count the number of files so we have initialized... main(String[] args) { File f = new File("C:/Text"); int count = 0
Java Count Vowels
Java Count Vowels       In this program you will learn how to count vowels in a String. Here you... a variable- count = 0. Now, we have applied a loop here which will go up
 

 

 

DMCA.com