Adil,
Formatting the code means changing your code to look something like below.
Doesn't it look better now? Isn't it amazing to see how much of a difference these few spaces can make to the readability of code. It makes it easy for us to see where a block starts and where it ends.
Another thing is, we don't code class names like that. The accepted standard is that class names start with a capital letter and when we have class names made up of more than one
word, we capitalize the first letter of each word.
Example -
MyClass
Inverter
C1 is better than c1 though a class name should also be meaningful and c1 or C1 or MyClass are far from it.
I know you've copied this code from somewhere, but this is just so you don't code such class names when you are writing your classes.
my problem is that i coudn't understand why we call m1() two tiems and i have just one output
When you say new c2(), you are creating a new c2 object. Through this object, you are invoking c2's m1 method. Now my question to you is what happens when you invoke c2's m1 method.
Hint - Anonymous classes. Question - Do you know what is an anonymous class? Do you know what is an inner class?
If not, I strongly recommend you to go through
http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html first. Read about Nested classes, Inner class examples, local classes, and anonymous classes.
Let us take this question after you've done that. What say?
Chan