JavaRush/Java Blog/Random EN/Java Understanding Questions
Hehabr
Level 13

Java Understanding Questions

Published in the Random EN group
members
I've been wanting to ask for a long time. When I see code like this: public class Solution { public Solution method1 (String s) { // bla-bla } } ... when a description of a class begins and a method that has the type of the same class is immediately described inside it, it always seems illogical to me. After all, the class has not yet been fully described and created, and in general, how can it be possible to use your own type for a method within itself? Now, if there were, for example, 2 classes: one is Solution, and the other, say Answer. And the Solution method1() method would be declared in the Answer class - then it would seem clear and logical. Those. first, a new class (data type) Solution is created, and only then, when it exists, you can start using it as a type to describe new methods. How to deal with this? Can anyone explain or advise what to read about this?
Comments
  • Popular
  • New
  • Old
You must be signed in to leave a comment
This page doesn't have any comments yet