Skip to content

Instantly share code, notes, and snippets.

@BalicantaYao
Created August 24, 2014 11:18
Show Gist options
  • Save BalicantaYao/d3a384433a9241c6bf3c to your computer and use it in GitHub Desktop.
Save BalicantaYao/d3a384433a9241c6bf3c to your computer and use it in GitHub Desktop.
PassByValue.java
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