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?

1

Answers

2014-09-12T01:09:26+08:00
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();
0