Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

10
LINES

< > BotCompany Repo | #1003598 // countChar - count occurrences of a character in a string

JavaX fragment (include)

static int countChar(S s, char c) {
  int n = 0, l = l(s), i = 0;
  while true {
    int j = s.indexOf(c, i);
    if (j < 0) break;
    ++n;
    i = j+1;
  }
  ret n;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1003598
Snippet name: countChar - count occurrences of a character in a string
Eternal ID of this version: #1003598/2
Text MD5: 47c965e384b5f539a54eff67f3e36f99
Author: stefan
Category: javaqx
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-08-03 14:07:07
Source code size: 177 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 539 / 1093
Version history: 1 change(s)
Referenced in: [show references]