Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ClassB {
- int numB = 0;
- public int getNumB(){
- return numB;
- }
- void createNumB(int Int){
- numB = Int;
- }
- }
- public class ClassA {
- ClassB b = new ClassB();
- // Returns numB from ClassA
- public int returnB(){
- return b.getNumB();
- }
- public static void main(String[]args){
- ClassA a = new ClassA();
- ClassB b = new ClassB();
- //My espectation is that b.createNumB(1) should update numB in ClassA
- b.createNumB(1);
- System.out.println(a.returnB());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement