Created
August 24, 2014 11:15
-
-
Save BalicantaYao/7206e9db08e6ee67c639 to your computer and use it in GitHub Desktop.
PassByValue.java
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
package practical.praxis1; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
public class PassByValue { | |
private static Logger logger = LoggerFactory.getLogger(PassByValue.class); | |
public static void main(String[] args) { | |
runCase1(); | |
runCase2(); | |
// | |
} | |
private static void runCase1() { | |
// Case1. From Pratical Java | |
int j = 10; | |
Point point = new Point(4, 4); | |
logger.info("Before Modify Point {}, j ={}", point, j); | |
setPointLocation(point, j); | |
logger.info("After Modify Point {}, j ={}", point, j); | |
} | |
private static void setPointLocation(Point pointInst, int j) { | |
pointInst.setLocation(5, 5); | |
j = 20; | |
logger.info("During Modify Point {}, j ={}", pointInst, j); | |
} | |
private static void runCase2() { | |
Integer test = new Integer(10); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment