Let Start from the core: Java – constructor – “Lets check the Instance of Frank Cake Class “

Image

1. My Understanding of Constructor – Java “not bahasa Jawe”?

  • Constructor is a special method that is use to initialize object of a class. All Java Object have Constructor, Even I not declare at java class, because any Java Class Compiler builds a default constructor.
  • Constructor does not have return Value.
  • Need to Understand More deeply how it work : “ Object must be explicitly constructed. The process of constructing an Object means, First – Finding Some Unused Memory in the heap that can Hold the Object. Second – Filling in the Objects instance Variable”
  • The name of Constructor has the same name with Class, Construtor method been called when object of clas is created.

Lets STarT – “Lets SQueeze Lemon into Frank Dough”

2. There are two Common Constructor:
2.1. Default Constructor.
2.2. parameterized constructor

2.1. Default Constructor
Lets Start to Create Frank Cake Default Constructor.

package javaconstructor;

Create a java program – constructor -“My Piece of Cake”

// Default constructor
public class cakeFrank {

// constructor method – default constructor
cakeFrank()
{
System.out.println(” Just Note of Recipe “);
}

public static void main(String args[]){
cakeFrank cf = new cakeFrank();
}

}

OUTPUT/run in java runtime: Just Note of Recipe

Lets Learn Deep Again , Why we need constructor:
Its Realy Nonsense if I wrote without knows the Benefit.

check It Out:
2.1.1. If there is no constructor , or You not COPY PASTE to get example exactly code from any site,and you missing constructor:
don’t worry, Constructor is automatically created the constructor. Look DoWN:

cake_constructor_default

2.1.1.1. The Purpose of COnstructor:- Default Constructor provides the Default values of the object.

2.1.1.1.1. What Is the Default Value???
null and 0

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s