Hi,
I was debugging an error I was getting with a java servlet. I was assigning a value to a Double in the class, however occasionally when I ran the servlet I was getting a random number as the value. Not sure if this has to do with using the wrapper versus primitive?
Here is a snippet of code:
public class MyClass extends HttpServlet {
private Double MinCost = 10000000.0;
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
// rest of code here ----
When I run the servlet, I sometimes get the value of MinCost to be some other number, and sometimes it is correct.
I have changed the code to just declare the variable MinCost but not assign it a value, and assign it a value later on in my doPost method.
Any explanation as to why this happens?
Thanks