fork download
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class Szukanie {
  5. public static int strfind(String gdzie, String co){
  6. StringBuilder pomoc = new StringBuilder("");
  7. int miejsce = 0;
  8. for (int i = 0; i < gdzie.length(); i++) {
  9. char znak = gdzie.charAt(i);
  10. if (!Character.isWhitespace(znak)){
  11. pomoc.append(znak);
  12. }
  13. else {
  14. if (co.equals(pomoc.toString())){
  15. miejsce = i;
  16. }
  17. else {
  18. pomoc = null;
  19. }
  20. }
  21. }
  22. return miejsce;
  23. }
  24.  
  25. public static void main(String[] args) {
  26. System.out.print("Podaj tekst: ");
  27. Scanner in = new Scanner(System.in);
  28. String tekst = in.nextLine();
  29. System.out.print("Podaj slowo: ");
  30. String slowo = in.nextLine();
  31. int wynik = strfind(tekst, slowo);
  32. System.out.println(wynik);
  33. }
  34. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:4: error: class Szukanie is public, should be declared in a file named Szukanie.java
public class Szukanie {
       ^
1 error
stdout
Standard output is empty