Monday, April 6, 2015

William Viterbo Galvão I am a guy who loves to program Java (Web) and C # Windows Forms. Also mourn


Object Oriented Programming - Method builder The constructor method is one that chamos when instantiate an object diastasis recti in many cases is responsible for initializing the object's state. He is like a method, only that it has no return type (not even void statement) and must have the same class name. It can be stated with any access modifier, even private. If it has a private constructor means Dezer that only the code within the class will have access to it, example:
class Foo {private Foo () {} private Foo foo; public static getInstance () {if (foo == null) foo = new Foo (); return foo; }} Class Bar {public Bar () {this ("Hi"); } Private Bar (String msg) {System.out.println (msg); }} If you do not put a constructor method in your class the compiler will put to you. Another important factor is that you can have a method with the name of a manufacturer, example:
class Foo {public Foo () {} void Foo () {}} // main new Foo () Foo ().; // End main this example it will run the constructor of the object and then in the following diastasis recti section diastasis recti the method void Foo. Whenever you establish inheritance of relationship you have to call in the constructor the super class constructor if you do not generate the compiler again does it for you, except for the super constructor require the passage of some parameter, diastasis recti for example:
class Foo () {Foo (String msg) {}} class Bar extends Foo () {bar () {super ("Hi"); }} Another important fater is knowing when to use "this" and the "super". The "this" is used when a constructor to call another constructor of the class, for example:
class Bar {public Bar () {this ("Hi"); } Private Bar (String msg) {System.out.println (msg); }} Since the super is used when a subclass calls the super constructor, example:
William Viterbo Galvão I am a guy who loves to program Java (Web) and C # Windows Forms. Also mourning jiu jitsu, karate and judo. I am a lover of martial arts and fight more than two years. Did technical course in ETEC Aristotle Ferreira, travel programming with an emphasis on Informatics (One year and six months) and am currently attending diastasis recti the FATEC Rubens Lara (Old FATEC BS), in the course Internet Systems. View my complete profile
2011 (15) September 2011 (7) 2011 (6) December 2011 (2) 2012 (7) March 2012 (4) April 2012 (1) October 2012 (2) Object Oriented Programming - Instance of Cla ... Object Oriented Programming - Method construct ...
William Viterbo Galvão. Model Awesome Inc .. Powered by Blogger.


No comments:

Post a Comment