Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Лаунчер, чтобы запускать
- public class ALauncher {
- public static void main(String[] args) {
- B b = new B();
- b.returnVariable();
- }
- }
- //ваш класс А
- class A {
- int variable;
- public A() {
- setVariable(5);
- }
- public void setVariable(int variable) {
- this.variable = variable;
- }
- public int getVariable() {
- return variable;
- }
- }
- //ваш класс В, с парой новых выводов
- class B {
- void returnVariable() {
- A a = new A();
- System.out.println("A.variable is "+a.getVariable());
- a.setVariable(6);
- System.out.println("A.variable is "+a.getVariable());
- a.setVariable(9);
- System.out.println("A.variable is "+a.getVariable());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement