1

I am getting an error:

Girl (String , String ) in Girl cannot applied to (String)

Here is my code:

package com.herprogramacion.toolbarapp;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;


public class Girls {

public static final String[] girlsNamesDummy = {
        "Catherine", "Evelyn", "Phyllis", "Beverly", "Michelle",
        "Denise", "Virginia", "Ruth", "Barbara"
};


public static List<Girl> ctrl(int count) {

   List<Girl> items = new ArrayList<>();




    for (int im = 0; im < count; im ++) {

        items.add(new Girl(girlsNamesDummy[im]));

    }

    return new ArrayList<>(items);
}}

Here's the girl.class and fully code provided.

public class Girl {

    private String name;
    private String yazi;
    private int idDrawable;

    public Girl(String name, String yazi) {
        this.name = name;
        this.idDrawable = getDrawable();
        this.yazi = yazi;
    }


    public String getName() {
        return name;
    }

    public int getIdDrawable() {
        return idDrawable;
    }


    private int getDrawable() {

        switch (idDrawable) {
            default:
            case 0:
                return R.drawable.girl1;
            case 1:
                return R.drawable.girl2;
            case 2:
                return R.drawable.girl3;
            case 3:
                return R.drawable.girl4;
            case 4:
                return R.drawable.girl5;
            case 5:
                return R.drawable.girl6;
            case 6:
                return R.drawable.girl7;
            case 7:
                return R.drawable.girl8;
        }
    }
}
1
  • Have you defined a constructor that takes a single String argument in your Girl class? Commented Aug 9, 2015 at 22:42

1 Answer 1

1

You should have posted the Girl class. From what I can say you have a problem with constructors. Where you have a 2 paramater constructor defined (String, String) and you are trying to call a 1 parameter construcctor (String) with this call:

new Girl(girlsNamesDummy[im])

Sign up to request clarification or add additional context in comments.

2 Comments

I have problem with this line; items.add(new Girl(girlsNamesDummy[im]));
@Fatih Yes, it is what I said before. In the Girl class you only have a 2 parameter constructor. So you need a constructor that takes 1 parameter such as: public Girl(String name)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.