السلام عليكم ورحمة الله وبركاته أنا عملت كود يحسب عدد مرات حدوث كل حرف داخل string لكن لم أعرف كيف اتغلب على مشكلة لو وجدت حرف تم حسابه من قبل كيف أعرف وأيضا كيف أستقبل حرف وأزيد في عدد مراته الموجود عندي هذا هو الكود ارجو المساعدة
import java.util.*;
public class Main {
static Scanner console= new Scanner(System.in);
public static void main(String[] args)
{
System.out.print("Please Enter aString ");
System.out.println();
String str =console.next();
char[]third =str.toCharArray();
for(int counter =0;counter<third.length;counter++)
{ char letter= third[counter];
int flage=0;
for (int i=0; i<third.length; i++)
{
if (letter==third)
flage++;
else continue;
}
}
}
public static void counter (int x)
{
int []count= new int[x];
// this method to store the number of occurrences of each
//alphabetical letter in the string
}
public static void read (int x)
{
// this method should recive acharacter
// then update its the corresponding counter
}
}