This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
hi i been working on this project all day and am hitting a wall, I am supposed to write a program that accepts data from the user and prints it to the console. it involves using inheritance. i have for the most part figured out how to write the classes now i am stuck with my main method. i dont know how to store the data in the class object this is my code so far please help im stuck
i attempted to write as follows
but i get redlines on netbeans, i dont understand. the object is to print the user data to the console.
why cant i simply pass this value to an object by typing -->
Person c = new Customer(firstName);
keep in mind im using inheritance and overriding the toString method, not sure if that makes a difference
im trying to create Person c = new Customer(variable value);
so that c equals the value of the user input so i can then print it. but netbeans wont allow me to do it.
There are 2 ways to achieve what you want to do. And your current approach (using empty constructor in those Person etc classes) does not match up with using parameterized constructors in your main method.
I hope you see the difference. And this is what Netbeans is telling you "there are no parameterized constructors"