This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Micro Frontends in Action and have Michael Geers on-line!
See this thread for details.
Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

extending an abstract Item + linking classes

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting an "invalid method delaration: return type required" error message in the constructor when trying to compile a sub-class of an abstract class.
Here is the code for the abstract class:



and here is the code for its subclass:

 
Mike Drozz
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the other problem i'm having is this:
I've created a Gui and an actionListener class; when I press the add button, the values are stored in temp variables. That's it.
What i'm TRYING to implement is to link that ActionListener class with the subclass of the abstract class (as detailed above), send the information aquired in the actionlistener class to that subclass, and create an object with those values and store them in an ArrayList.
It's a bit complicated, so that's why i need a little help

here's the ActionListener class:
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For part 1, your code is:
public phone (String name, String display, String work, String home, String mobile) {
which has a lower-case "p" on "phone" whereas the class name is an upper-case "P". Since these don't match, the compiler assumes the constructor is actually a method declaration and so flags that the return type is missing. Make the "p" upper-case.
For part 2, the ActionListener could instantiate the Phone class using the above constructor and place the reference in an ArrayList. The missing piece is where that ArrayList is defined. One way is to pass it to the Listener class in a constructor, another is to provide a setList() method in the listener and call it with the ArrayList reference.
Hope this helps a little. Good Luck
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic