Are methods and builders the same?

Asked

Viewed 120 times

3

Some sources say that constructor is a special type of method, while others say constructors are not methods. Some say, too, that although they are different the JVM treats them the same way. After all, a constructor is a type of method or are different things with only a few aspects in common?

  • I would like to point out that this question: http://answall.com/questions/104707/dif%C3%A7a-entre-m%C3%A9todo-e-construtor also made by me questions only the difference of one aspect between the structures (methods and builders).

  • 5

    If you’ve asked the other question, I don’t understand the purpose of this

  • 2

    Cite the sources that say these things. Understanding may be wrong, or sources may not be reliable.

  • As I said to the other questions one aspect between the two, excerpt from the other question: "Maybe it is not the main difference between them but, it is correct to say that constructors allocate space in memory, while the methods do not?". In this I ask if a method and a builder are the same thing, I see a difference between the questions. I could be wrong but I think it’s worth doing this.

  • @bigown now I have to leave, later I edit the question.

1 answer

4

Yes, builders are methods.

And it can be said that they are "special", for they can only be called in the instance of a class.

You can apply the same security access, such as public, private, protected.

  • 1

    The constructor is also called when invoking super() or this(). Nor can it be synchronized

  • Exact @Pabloalmeida, all builders are síncronos, and can never be assíncronos.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.