Home > Enterprise >  I can't seem to find out why I keep getting the error "Invalid method declaration; return
I can't seem to find out why I keep getting the error "Invalid method declaration; return

Time:11-26

I am trying to make field of UUID type...

    private final UUID singerID;
    private final UUID musicID;
   
    Singer() {
        this.singerID = UUID.randomUUID();

    }
    
    Music() {
        this.musicID = UUID.randomUUID();

And I keep getting the error "invalid method declaration; return type required" at Singer() { I am very new to java been like 2 weeks, so if you could go slow on me it would mean a lot to me!

CodePudding user response:

You are using the constructor syntax for Singer() when the class is Music.

Change your code to and remove Singer() constructor,

public Music() {
   this.musicID = UUID.randomUUID();
   this.singerID = UUID.randomUUID();
}
  • Related