I have a lab for a high school comp sci class, I take integer input in the driver class, and pass that to a method in another class that uses the number to do a calculation and return the answer.
Whats an easy way of doing this?
Depending on what you're trying to produce with the output, you can simply use a "get" function inside your driver class after you've accepted your user input. The purpose of this function is to simply return the value of your variable.
Eg.
public int getVariable() {
return x;
}
And then
secondClass.calculation(driver.getVariable());
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.