Is it possible to refer to a private method of some class from another instance of the same class?
Explanation
Code example:

class X {
  private int getX() {
    return 5;
  }

  public int get2X() {
    X x = new X();
    return 2 * x.getX();
  }
}

Refer from where? Yes, if from inside of given class, no if from other class.

2015 Nov 28, 11:36:51 AM

Java
Java Quiz
Start Quiz

or Read more about Java Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback