Monday, August 20, 2012

How to count word in string using java

Number of words are: 6

package com.swain.cell;

import java.util.StringTokenizer;

public class CountWords {

        * @param args
       public static void main(String[] args) {
              // TODO Auto-generated method stub
        String st="how to count word in java?";
        int count=0;
        StringTokenizer stk=new StringTokenizer(st," ");
            String token=stk.nextToken();
        System.out.println("Number of words are: "+count);



Java Quick Program

1. Write a Code to generate Random numbers public class GenerateRandomNumbers { public static void main(String[] args) { System.out...