java - Type The nested type CubeRanks cannot hide an enclosing type -


this question has answer here:

i have problem java plugin. never had before. normal went good.

here code:

package me.brian.cuberanks;  import me.brian.cuberanks.cuberanks; import org.bukkit.plugin.java.javaplugin; import java.util.arraylist; import java.util.logging.logger; import org.bukkit.chatcolor; import org.bukkit.command.command; import org.bukkit.command.commandsender; import org.bukkit.entity.player; import org.bukkit.plugin.pluginmanager;   public class cuberanks {      public class cuberanks extends javaplugin {          public static cuberanks plugin;         public final logger log = logger.getlogger("minecraft");         public boolean enabled = false;         public final playerlistener pl = new playerlistener(this);         public final arraylist<player> orehunterusers = new arraylist<player>();         public string cr = "[cuberanks] ";           @override         public void onenable() {             log.info(cr + "is enabled.");                pluginmanager pm = getserver().getpluginmanager();             pm.registerevents(pl, this);          }          @override         public void ondisable() {             log.info(cr + "is disabled.");         }          @override         public boolean oncommand(commandsender sender, command cmd, string commandlabel, string[] args) {             if(commandlabel.equalsignorecase("cuberanks")) {                 if(args.length==0) {                     if(!enabled) {                         enabled = true;                         ((player) sender).sendmessage(chatcolor.green + cr + "is enabled");                     }                     else {                         enabled = false;                         ((player) sender).sendmessage(chatcolor.red + cr + "is disbaled");                     }                 }             }             return false;         }     } } 

can see whats wrong?

whole error code:

description resource path location type nested type cuberanks cannot hide enclosing type cuberanks.java /cuberanks/src/me/brian/cuberanks line 16 java problem

photo of error: this error

you have class enclosing class of same name. i'm not sure why have outer cuberanks class, either rid of outer one, or rename 1 of them.

public class cuberanks { // remove or rename      public class cuberanks extends javaplugin { // or rename         ...     }  } 

syntactically, reason why can't have inner class same name outer class remove following ambiguity:

public class ambiguous {     public class ambiguous {         ambiguous a; // <-- type ambiguous referring here?     }  } 

you argue recent enclosing type name take precedence, how refer outer type? while there theoretically ways design language around of that, it's easier disallow it.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -