Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package zadanie27;
- public class WhatPositionOfSign {
- public static void FindLetterInString(String text, String letter){
- int i = 0;
- while((i=(text.indexOf(letter,i)+1))>0){
- System.out.println("Pozycja wystąpenia od początku: "+i);
- }
- int occurrences = 0;
- char letterAsChar = letter.charAt(0);
- for(char c : text.toCharArray()){
- if(c == letterAsChar){
- occurrences++;
- }
- }
- System.out.println("Liczba wystąpnień: " + occurrences);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement