Tuklasin ang maliwanag na mga sagot sa iyong mga tanong sa IDNStudy.com. Ang aming komunidad ay narito upang magbigay ng detalyadong sagot sa lahat ng iyong mga katanungan.

justin is a student in it102 and they are now in the topic classes and objects. he learned how to create an objects and method. his problem now is he doesn't know the operator he needs to use to have the objects access the method in his class. what operator should justin use?

Sagot :

If I understand the question correctly, you're asking how an object would use a method. Basically just use  <objectname>.<methodname>();"

For example:
public class Calculator(){
private int x = 4;
private int y = 5;

public void add(){
System.out.println(x+y);
}
}

In your main method, you would instantiate Calculator  by saying

Calculator c = new Calculator();

and you could add by saying

c.add();