Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i was run the code it's showing
Donor does not define a no-argument constructor. If you are using ProGuard, make sure these constructors are not stripped.


How to solve ?

What I have tried:

package com.example.blood_donor;

public class Donor {
    private final String name;
    private final String age;
    private final String mobile;
    private final String state;
    private final String city;
    private final String gender;
    private final String blood;
    private final String mail;
    private final String pin;

    public Donor(String name, String age, String mobile, String state, String city, String gender, String blood, String mail, String pin) {
        this.name = name;
        this.age = age;
        this.mobile = mobile;
        this.state = state;
        this.city = city;
        this.gender = gender;
        this.blood = blood;
        this.mail = mail;
        this.pin = pin; }
    public String getName() {
        return name;
    }
    public String getAge() {
        return age;
    }
    public String getMobile() {
        return mobile;
    }
    public String getState() {
        return state;
    }
    public String getCity() {
        return city;
    }
    public String getGender() {
        return gender;
    }
    public String getBlood() {
        return blood;
    }
    public String getMail() {
        return mail;
    }
    public String getPin() {
        return pin;
    }
}
Posted
Updated 23-Dec-21 19:52pm

1 solution

When a Java class has no constructors at all, the system automatically adds a default no argument constructor - but if you define any constructor in the class, the default no-arg version is no longer created for you.

At a guess, you are using JavaBeans which requires a no argument constructor: so you will need to add your own to you parameterized version.
 
Share this answer
 
Comments
zsurya 24-Dec-21 1:57am    
Hi OriginalGriff,
How to add parameterized version
OriginalGriff 24-Dec-21 3:16am    
You already have a parameterized version:
public Donor(String name, String age, String mobile, String state, String city, String gender, String blood, String mail, String pin) {
...
What you need is a version without any parameters.
zsurya 27-Dec-21 2:15am    
hi,
what i am do?
OriginalGriff 27-Dec-21 2:21am    
Would you care to try that again, in English this time?
zsurya 27-Dec-21 3:27am    
yes, I am tried many times, this problem is not solve

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900