You can call it as part of the same statement:
new RegularAxis(){
public String returnHello(){
return "hello";
}
}.returnHello();
Or you can capture the anonymous type with a var
variable in Java 10+ (thanks @Lesiak):
var lon = new RegularAxis(){
public String returnHello(){
return "hello";
}
};
lon.returnHello();
Otherwise, you'll have to declare it as a proper class:
class IrregularAxis extends RegularAxis {
public String returnHello(){
return "hello";
}
}
IrregularAxis lon = new IrregularAxis();
lon.returnHello();