Skip to content
Advertisement

Eclipse says The constructor Email() is undefined

I am tring to expand on a tutorial I was following Java Project Step by step Build An Email Administration Application (https://www.youtube.com/watch?v=U3Ibvu0htNs&t=386s). I am trying to use getters and setters to allow the encapsulation to do its job, and eventually allow a user to enter their own name instead of having a preset name in the variable. I know the code is messy I have been playing with this code longer then I would like to admit. XD

JavaScript
JavaScript

Advertisement

Answer

a) The line “Email s = new Email();” should work fine. Just ensure whether you had saved the program before running it.But you’ll get a null pointer exception at

email = firstName.toLowerCase() + “.” + lastName.toLowerCase() + “@” + department.toLowerCase() + “.” + companySuffix.toLowerCase();

b) The error you mentioned might occur only when you un-comment the line “Email em1 = new Email(“John”, “Smith”);” and execute the program as there are no parameterized constructor in the class Email. At that time you might get the error as “The constructor Email(String, String) is undefined”.

But the current constructor instantiation should work fine.Just ensure(a)

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement