I have a function that is searching for max number in the array. I want to make the function to search for more than one word that is entered from console.
As example I enter two words(car,ride) they're added to array and then "surasti" function is comparing them if they're in the array.
I have tried to do it on my own, but I'm a started and it seems too hard :(
Function that is searching:
public static produktas[] surasti (produktas G[], int n){
    produktas A[] = new produktas[1]; 
    produktas max = G[0];
    for (int i=1; i<n; i++)
        if (max.gautiSvori()<G[i].gautiSvori()) max = G[i];
    A[0]=max;
    return A;
}
The code that is calling that function (A is the array that you have to search in.):
    case 5:
        B = surasti(A, n);
        System.out.println("Sunkiausias gyvunas yra:");
        spausdinti_sar_ekrane(B, B.length);
        break;
The produktas class:
class produktas {
    private String pavadinimas;
    private String salis;
    private Double svoris;
    private Double kaina;
    produktas() {}
    produktas(String pav, String salis, double svoris, double kaina){
        pavadinimas = pav;
        this.salis = salis;
        this.svoris = svoris;
        this.kaina = kaina;
    }
    public String gautiPav (){
        return pavadinimas;
    }
    public String gautiSali (){
        return salis;
    }
    public double gautiSvori (){
        return svoris;
    }
    public double gautiKaina (){
        return kaina;
    }
}
When I try to change the function to this (don't know if its working fine, can't test it):
public static produktas[] surasti (produktas G[], int n){
        try{
        BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
        produktas A[] = new produktas[5];
        for (int j=0; j<5; j++){
        System.out.println("Kokio produkto ieskosime?");
        String found = in.readLine();
        for (int i=1; i<n; i++){
            if (found.equals(G[i].gautiPav())){ 
                A[j] = G[i];
            }
        }
    } 
    return A; 
    } catch(IOException ie){
            ie.printStackTrace();
        }
    }
When I try this code I get this error at public static produktas[] surasti (produktas G[], int n){ line:
This method must return a result of type produktas[]