class - Should this method be static? -


I am quite new to Java and currently debugging a program. So I have a class in which there is a simple method with some calculation basically when I call this method to use a variable from another category (this is part of an array, from which to some Calculating) I need the calculation that I need. Then I call it once again in the second category, it re-calculates and my number becomes compromised. Is there a way to take this method into some values, calculate and then?

This is the array class, I need to instantiate it and after that I should have a constant when I call it again, is there no way when I just say arrays?

In the second category I use PlanetMeat = New Planmat (), like some evening. Content (FSI, FS, FO); And pm.rh0 [48] for calling an array;

  public class scheme (constant = new constant); Double GPa = con.GPascals; Main = new main (); Public int i; Public Inc. EOS []; Public double rho0 []; Public double c []; Public double nn []; Public Double KS []; Public Double KSP []; Public Zero Content (Double FSI, Double FS, Double FO) {i = 0; EOS = new int [51]; Rho0 = new double [51]; C = new double [51]; Nn = new double [51]; Ks0 = new double [51]; KSP = new double [51]; Double FFES = (((MMF / Con. MIS) + 1) * FS); Double FFCSI = (((MMF / Con. MCI) (1) * FSI); double FFEO = (((0.950 * con.m_fe) + con.m_o) / (1.95 * con.m_o) * FO); Double FFE = 1.0 - FFES - FFEC - FFEO; I = 48; EOS [I] = 1; Rho0 [i] = 1.0 / ((FFE / ROE [3]) + (FFEC / ROE [21]) + (FFEO / ROE [22]) + (FFES / ROE [13]); KS 0 [I] = FFE * KS [3] + FFEC * KS [21] + FFEO * KS [22] + FFES * KS [ 13]; Ksp [I] = FFE * KS [3] + FFESI * KS [21] + FFEO * KS [22] + FFES * KS [13]; C [I] = 0.0; N [i ] = 0.0;   

}}

There are two isys:

first : You should write the set and write methods, set to call Set the value to the method and get the value to be get value you set the values ​​and say that in class 1 you set the value and now If you want the same value in class 2, you can use your method as an array Will call for Rapt and pass the array as arguments manufacturer of Class 2. .

II : You can pass the whole object to class 2 constructor and use that object in that class, your values ​​will be the same and not compromised with the data. But for that you have to make serialjob eligible on your data class (that you are using in both of them.)

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -