I am trying to understand this line that is in a Servlet. Please tell me if I am correct or wrong on how I interpret the bolded line below. boolean dataExists = new Baseball().hitBall(String Mays, String McCovey);
The line creates a boolean datatype called dataExists which is a object reference that is assigned to a new Baseball type object where it is calling Baseball no argument constructor AND it is calling a (non static) boolean two parameter method called hitBall? For example the Baseball no arg constructor could have some code with the Database connection statement and the boolean method hitBall would have this as its signature method: public boolean hitball(String Mays, String McCovey) [ April 10, 2007: Message edited by: Mike Jenkins ]
Originally posted by Mike Jenkins: ...The line creates a boolean datatype called dataExists which is a object reference that is assigned to a new Baseball type object...
Just to clarify a bit further, boolean with a lowercase 'b' is a primitive type -- not an object. (The boolean wrapper class uses an uppercase 'B'.) So instead of referencing an object, dataExists will only hold a primitive value of true or false.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Joined: Jul 23, 2006
Thanks for replies and my apology for originally putting in Servlet Forum. From both responses: "An important nuance that your description seemed to miss is that a reference to the newly created Baseball instance is not stored anywhere." and "So instead of referencing an object, dataExists will only hold a primitive value"
I assume there is no reference in this: boolean dataExists = .. because the boolean is a primitive data type BUT if it said this: Boolean dataExist = .. then it would be a reference to a Baseball instance (object)? [ April 10, 2007: Message edited by: Mike Jenkins ]