Syntax: class Point2D.Double

J

Jenny

Hi,

I do not understand the line below.

public static class Point2D.Double
extends Point2D

The API Doc says it is a nested class. But a nested class should be
defined inside the Point2D, not to use "extends", right?

Could you tell me how to define a class name with . in it? I have a
class Test. I create a new class

public class Test.p extends Test {
}

It give me an error.

Thanks a lot.
 
V

VisionSet

Jenny said:
Hi,

I do not understand the line below.

public static class Point2D.Double
extends Point2D

The API Doc says it is a nested class. But a nested class should be
defined inside the Point2D, not to use "extends", right?

No, Sun have it right, funnily enough ;-)

an inner class can extend another class just fine.
Could you tell me how to define a class name with . in it? I have a
class Test. I create a new class

public class Test.p extends Test {
}

It give me an error.

So the Point2D example would have looked something like

public class Point2D {

public static class Double extends Point2D {}
}

then Point2D.Double is the qualified name of the inner class.

The dot notation arises as an effect of nesting you don't explicitly define
it.
 
J

Jenny

Thank you!

So the line below is a description, not the Java code.

public static class Point2D.Double extends Point2D
 
M

Murray

Jenny said:
Thank you!

So the line below is a description, not the Java code.

public static class Point2D.Double extends Point2D

Yes, but that is also how classes external to Point2D will reference the
class.

Point2D.Double dbl = ....

Internally though it is defined as VisionSet said.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top