Home java Can't call the

Can’t call the

Author

Date

Category

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.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions