Setting a value in a class is not working

StefSoma

New Member
I have a class called monetary\[code\]public class Monetary{ double value; String type; public Monetary() { value = http://stackoverflow.com/questions/15563207/0; type =""; } public double getValue() { return value; } public void setValue(double x) { x = this.value; }\[/code\]and i was testing get and set methods so i made a testing class as the following\[code\] public class test { public static void main(String [] args) { double test = 5000; Monetary testM = new Monetary(); testM.setValue(5000); System.out.println(testM.getValue()); }}\[/code\]The problem is that the result java prints is not 5000.0, but 0. I don't get why this is happening. Aren't these methods correct?
 
Back
Top