Name: Anonymous 2013-09-19 6:47
Small problem with changing values in another class then viewing said change.
Ship class:
public class Ship {
int xOffset = 0;
String toString {
System.out.println(xOffset);
}
}
TestShip Class
public class TestShip {
public static void main(String[] args) {
Ship ship = new Ship();
ship.xOffset = 1;
system.out.println(ship.toString);
system.out.println(ship.xOffset);
}
The first out put gives me 0, the second output gives my 1. Why?
Ship class:
public class Ship {
int xOffset = 0;
String toString {
System.out.println(xOffset);
}
}
TestShip Class
public class TestShip {
public static void main(String[] args) {
Ship ship = new Ship();
ship.xOffset = 1;
system.out.println(ship.toString);
system.out.println(ship.xOffset);
}
The first out put gives me 0, the second output gives my 1. Why?