I wrote this code to operate with lengths. However , the value of Lt1 changes when I call theaddmethod. I am new to JAVA ; can't understand what's gone wrong.

---------------- please helppublic class mcmLength { int m,cm,mm,temp,temp1,temp2; mcmLength(int met,int cms,int mils){ m=met; cm=cms; mm=mils; } mcmLength(int mils){ m=mils/1000; cm=(mils - m*1000)/10; mm=mils - (m*1000) - (cm*10); } mcmLength(double cms){ temp=(int)cms*10; m=temp/1000; cm=(temp - m*1000)/10; mm=temp - (m*1000) - (cm*10); } mcmLength(){ m=cm=mm=0; } double Area(mcmLength L2){ return (this.m*1000 + this.cm*10 + this.mm)*(L2.m*1000 + L2.cm*10 + L2.mm)/1000000; } String add(mcmLength L2){ temp=(this.m+L2.m)*1000 + (this.cm+L2.cm)*10 + (this.mm +L2.mm); m=temp/1000; cm=(temp - m*1000)/10; mm=temp - m*1000 - cm*10; return Integer.toString(m) + " m " + cm + " cm " + mm + " mm" ; } String sub(mcmLength L2){ temp1= this.m*1000 + this.cm*10 + this.mm ; temp2= L2.m*1000 + L2.cm*10 + L2.mm; temp=(Math.max(temp1,temp2)- Math.min(temp1,temp2)); m=temp/1000; cm=(temp - m*1000)/10; mm=temp - m*1000 - cm*10; return Integer.toString(m) + " m " + cm + " cm " + mm + " mm " ; } public String toString(){ return Integer.toString(m) + " m " + cm + " cm " + mm + " mm "; } } -------- public class Test { public static void main(String[] args){ int i = (int)(Math.random()*10000); double d = Math.random()*1000; final mcmLength Lt1 = new mcmLength(i); final mcmLength Lt2 = new mcmLength(d); System.out.println("Line 1 : " + Lt1); System.out.println("Line 2 : " + Lt2); System.out.println("\nSum : " + Lt1.add(Lt2)); System.out.println("\nLine 1 : " + Lt1); System.out.println("\nDiff : " + Lt1.sub(Lt2)); System.out.println("Area = : " + Lt1.Area(Lt2) + " sq.m."); } }