• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

SoftwareTestingo - Interview Questions, Tutorial & Test Cases Template Examples

SoftwareTestingo - Interview Questions, Tutorial & Test Cases Template Examples

  • Home
  • Interview Questions
  • Java
  • Java Programs
  • Selenium
  • Selenium Programs
  • Manual Testing
  • Test Cases
  • Difference
  • Tools
  • SQL
  • Contact Us
  • Search
SoftwareTestingo » Java » Java Programs » Write a Program to Find Out No Of Occurrence Of a Character?

Write a Program to Find Out No Of Occurrence Of a Character?

Last Updated on: November 4, 2018 By Softwaretestingo Editorial Board

What We Are Learn On This Post

  • Write a Program to Find Out No Of Occurrence Of a Character?

Write a Program to Find Out No Of Occurrence Of a Character?

package com.java.Softwaretestingblog;
public class FoundNoOfOccurance {
   public static void main(String[] args) {
      // TODO Auto-generated method stub
      String s="i am monoj good boy";
      char c='o';
      int total_size=s.length();
      int replace_sie=s.replace("o", "").length();
      System.out.println(total_size +"\t"+replace_sie);
      int count=s.length()-s.replace("o", "").length();
      System.out.println("Number of occurances of 'a' is= "+ count);
   }
}
Check Also: Find the Smallest Number in An Array

Output:

19 14
Number of occurrence of 'a' is= 5

    Filed Under: Java Programs

    Reader Interactions

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    Primary Sidebar

    Join SoftwareTestingo Telegram Group

    Categories

    Copyright © 2022 SoftwareTestingo.com ~ Contact Us ~ Sitemap ~ Privacy Policy ~ Testing Careers