Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Example3 {
- private int strpos(String text, char z) {
- boolean j = true; // sprawdza czy było przynajmniej jedno wystąpienie
- for (int i = 0; i < text.length(); i++) {
- if (text.charAt(i) == z) {
- System.out.println(i + 1);
- j = false;
- }
- }
- if (j == true)
- return -1;
- else
- return 1; // bo musi coś zwrócić
- }
- public static void main(String[] args) {
- Example3 s = new Example3();
- System.out.println(s.strpos("belzebub", 'b'));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement