I cannot understand why an object is created this way

S

Shawn

I don't understand such code:

Suppose I have a class called MyClassA already:

public class MyClassA()
{
...
public void doThis()
{
...//code
}

} //end of MyClassA

My problem is the following. When I created an object, instead of like
tradition ( ref_name = new ClassName() ), it follows a block, which
includes some new methods. For example:

public class MyClassB()
{
private MyClassA classA = new MyClassA() {
public void doThat() {

} //end of doThat
};
}

What does this mean? Is that the object classA NOW actually has both
methods to use (doThis(), doThat())? What is the name of such a technique?

Thank you very much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,190
Latest member
ClayE7480

Latest Threads

Top