Only I start learning Java and do not understand why I can’t call the Zerotoone method to variable i. Does not appear in the Ide context menu. What is the error here?
Public Class Method {
Public Static Void Main (String [] Args) {
int i = 0;
** i.zerotoone (); **
}
Private Int Zerotoone (Int A) {
if (a == 0) {
a = 1;
}
RETURN A;
}
}
Answer 1, Authority 100%
Zerotoone (i);
– this is how the challenge is done. In Java, a straight line of calls, which is indicated by the parameter, is transmitted by the argument.
and since the Main
method is static, then call Zerotoone
you need at the object: New Method (). Zerotoone (i);
. Or make a static zerotoone
method>(Private Static Int Zerotoone (int a)
) and call directly, and not through the object.