| Task: | Lehmät | 
| Sender: | adex720 | 
| Submission time: | 2022-10-31 16:27:50 +0200 | 
| Language: | Java | 
| Status: | COMPILE ERROR | 
Compiler report
input/B.java:8: error: incompatible types: String[] cannot be converted to String
        String koot = scanner.nextLine().split(" ");
                                              ^
input/B.java:10: error: array required, but String found
        int korkeus = Integer.parseInt(koot[0]);
                                           ^
input/B.java:11: error: array required, but String found
        int leveys = Integer.parseInt(koot[1]);
                                          ^
input/B.java:26: error: bad operand types for binary operator '&&'
                        if (rivi.charAt(i1+1) && alkanut){
                                              ^
  first type:  char
  second type: boolean
4 errorsCode
import java.util.Scanner;
public class B {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String koot = scanner.nextLine().split(" ");
        int korkeus = Integer.parseInt(koot[0]);
        int leveys = Integer.parseInt(koot[1]);
        boolean alkanut = false;
        boolean loppunut = false;
        int lehmia = 0;
        for (int i = 0; i < korkeus; i++) {
            String rivi = scanner.nextLine();
            if (loppunut) continue;
            boolean sisalla = false;
            for (int i1 = 0; i1 < leveys; i1++) {
                char nykyinen = rivi.charAt(i1);
                if (nykyinen == '*') {
                    if (sisalla ) {
                        if (rivi.charAt(i1+1) && alkanut){
                            loppunut = true;
                            break;
                        }
                        sisalla = false;
                        break;
                    } 
                    alkanut = true;
                    sisalla = true;
                    continue;
                }
                if (nykyinen == '@' && sisalla) {
                    lehmia++;
                }
            }
        }
        
        System.out.print(lehmia);
    }
}