From 1bc95e9efa97268480a3505b1d8ef977826f590b Mon Sep 17 00:00:00 2001 From: imaryankr <83204723+imaryankr@users.noreply.github.com> Date: Tue, 11 Oct 2022 15:09:24 +0530 Subject: [PATCH] Create frequency.java --- frequency.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 frequency.java diff --git a/frequency.java b/frequency.java new file mode 100644 index 0000000..a4281b5 --- /dev/null +++ b/frequency.java @@ -0,0 +1,16 @@ +public class Frequency { + + public static void main(String[] args) { + String str = "This website is awesome."; + char ch = 'e'; + int frequency = 0; + + for(int i = 0; i < str.length(); i++) { + if(ch == str.charAt(i)) { + ++frequency; + } + } + + System.out.println("Frequency of " + ch + " = " + frequency); + } +}