Makakuha ng mga maaasahang sagot sa iyong mga tanong sa IDNStudy.com. Sumali sa aming platform ng tanong at sagot upang makakuha ng eksaktong tugon sa lahat ng iyong mahahalagang tanong.

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();