K
K
krembrule20162019-01-18 22:19:19
Java
krembrule2016, 2019-01-18 22:19:19

How is such a syntactic construction implemented?

Hello!
Using a variable of type Rectangle2D, we can write it like this:

Rectangle2d ourscreen = new Rectangle2d(minX, minY, width, height);

Everything is clear here, a variable is created and it will refer to an instance of the class, fields are filled, etc. etc.
But, in someone else's code, I found this:
Rectangle2D ourScreen = Screen.getPrimary().getBounds();

What is going on here is not entirely clear to me. Because the level of knowledge of the language is not very high, then the scrolling of the Rectangle2d class did not give me much.
It is clear that in the Screen class we refer to its methods, but
1. getPrimary().getBounds() - what is this paired function call and how does it work? I understand that this is possible only if the functions are described in one class?
2. we specified that the variable has the Rectangle2d type, but we never created the object. getBounds() is clear, it returns a Rectangle2d object, but how does this fit into getPrimary()? And what goes into our ourscreen variable? I'm assuming it's like a fuse? If as a result of the work of getPrimary() you get the following condition: DDD in general, is it something with the primary screen, then getBounds() will no longer work and everything is ashes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aol-nnov, 2019-01-18
@krembrule2016

There is a Screen singleton that has a Rectangle2d type field and a getter for it - getBounds.
Based on the data obtained, I recommend proceeding to Google to deepen knowledge on the subject. :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question