Last active
August 29, 2015 13:56
-
-
Save sivabudh/9202632 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object2 { | |
int y, x, z; | |
Object2 () { // constructor | |
y = 5; x = 2; z = 1; | |
} | |
public int doAnother() { | |
y += 1; | |
return y; | |
} | |
} | |
class Untitled { | |
public void doSomething( Object2 obj2 ){ | |
int newY = obj2.doAnother(); | |
System.out.println(newY); | |
} | |
public static void main(String[] args) { | |
Untitled u = new Untitled(); | |
Object2 obj2 = new Object2(); | |
Object2 obj3 = new Object2(); | |
u.doSomething(obj2); | |
u.doSomething(obj2); | |
u.doSomething(obj3); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output is:
6
7
6