Java using “extends” with scope-resolution/“dot” o

2019-02-25 05:33发布

I just came across this while reading some code and I have absolutely no idea what it means. I tried googling and whatnot but I got nothing, probably due to a lack of vocabulary. The code:

public final class GeneralPath extends Path2D.Float 
{
    // code and whathaveyou
}

What I know so far:

So I dont have any questions regarding the "public final class ClassName extends" portion, but I don't understand the presence of the dot/scope-resolution operator in the superclass designation. For starters, I imagine that someone is going to say something like "Java doesn't have a scope-resolution operator" to clarify some difference in nuances between Java and Cpp/other-OOP-languages, which is fine, as I appreciate knowing subtle distinctions like that. The "private" keyword killed me in a hw assignment once and I wish someone had noted the difference between "private" in Java and C then.

Im confused because clearly it is not referencing a member of the superclass, as the "member" is capitalized, and even if it were, it would seem redundant to reference a member of an object rather than just the object class itself. Furthermore, I failed to find information on the subject since most people who write java how-to's tend to start with the simpler concepts like "basic" class inheritance, and so I couldn't find anything involving the "dot" operator in relation to using the "extends" keyword.

In case I am using too many technical terms, I want to know why they used the dot operator for "Path2D.Float", or at least, what the dot operator does in this context.

Thanks a million!

1条回答
Anthone
2楼-- · 2019-02-25 06:08

The GeneralPath class is extending a class Float that is nested inside the Path2D class, which is defined something like this:

public class Path2D {
    public static class Float {
       // ...
    }
    // ...
}
查看更多
登录 后发表回答