

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Reading – Sections 7.5 and 7. Quiz – Monday, March 28 Last time we looked at the rules for calling one class from another. We also looked at method style Calling one method from another method in the same class What are the rules for calling one method from another? Within any particular class: An instance method can call another instance method on the same object - don't need to use an object name, as we already have the this object. (can invoke using this.method() ). An instance method can call a class method in the same class - no class name is required. A class method can call another class method in the same class - no class name is required. A class method cannot call an instance method - why not? Class X { private int value; public static void method1( int a ) { method2( a ); // Not valid } public void method2( int a ) { value = a; } } Method Style A method provides functional abstraction. What’s abstraction?
Let’s look at an example What does the program Example.java do? Compare with Example2.java Good properties for methods: