Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args)
- {
- count("Hallo, Wie gehts? Test,");
- }
- public static void count(String txt)
- {
- char semi = ';';
- char komma = ',';
- int counter = 0;
- int counter2 = 0;
- for(int i = 0; i <= txt.length(); i++)
- {
- if(txt.charAt(i) == semi)
- {
- counter++;
- }
- if(txt.charAt(i) == komma)
- {
- counter2++;
- }
- }
- System.out.println(counter);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement