String s = "aaaljlfeakdsflkjsadjaefdsafhaasdasd"; // Number of occurrences int num = 0; //
Loop through each character , Determine whether it is a character a , If it is , accumulative frequency for ( // Enter code ) { // Get each character , Determine whether it is a character a if ( // Enter code )
{ // Cumulative statistics num++; } } System.out.println(" character a Number of occurrences :" + num);

1.
int num = 0; for ( int i=0;i<s.length();i++ ) { if ( s.charAt(i)=='a' ) {
num++; } }
2.bytes array
int num = 0; byte[] bytes=s.getBytes(); for ( int i=0;i<bytes.length;i++ ) {
if ( bytes[i]=='a' ) { num++; } }
3. Using arrays char
char[] c=s.toCharArray(); for ( int i=0;i<c.length;i++ ) { if ( c[i]=='a' ) {
num++; } }

4. utilize substring(startindex,endindex) String
for ( int i=0;i<s.length();i++ ) { String s1=s.substring(i,i+1); if (
s1.equals("a")) { // Notice this place can't be 'a'. num++; } }
Common ways to attach strings , Please keep in mind

Technology
©2019-2020 Toolsou All rights reserved,
TP6 Application examples of verifier and correct verification data ESP8266/ESP32 System : Optimize system startup time 2021 year 2 Chinese programming language ranking 2021 year 1 Monthly programmer salary statistics , average 14915 element CSS architecture design It's not depravity that's terrible , It's about knowing you're falling Gude Haowen serial - You deserve to be an engineer ( Preface ) Software testing BUG describe C Course design of language programming of 《 Student achievement management system 》vue In the project axios Global encapsulation of