-1

How can i call a variable (private double balance) from a superclass in subclass if that variable is private in java?

public class Account {

private double bal;

}

I need to call it from this subclass:

public class SavingAccount extends Account {
private int interesi;
public SavingAccount(int a, int interesi){
    super(a);    
    this.interesi = interesi;
}

1 Answers1

2

You can either use getters and setters, or use the protected accessibility which allows access by subclasses.

apetranzilla
  • 5,331
  • 27
  • 34