[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
String name = message[1]; -------------------------------------------------------------------------------------------- refer pt 1
String address = message[2]; .......................................upto 30 values;
and then we are using these String references to create an object of bean class using setter methods.
myBean.setName(name); --------------------------------------------------------------------------------------------- refer pt 2
myBean.setAddress(address);
“The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'.”
K Abhijit wrote:
String name = message[1]; -------------------------------------------------------------------------------------------- refer pt 1
String address = message[2]; .......................................upto 30 values;
and then we are using these String references to create an object of bean class using setter methods.
myBean.setName(name); --------------------------------------------------------------------------------------------- refer pt 2
myBean.setAddress(address);
Please note that @ Ref pt 1 as well as pt 2 you ARE NOT CERATING any String object; your are decaring REFERENCES (pointers) to String Obejct.
String Object is constructed ONLY IF WE USE NEW operator like new String("TEST"); else String INTERN pool is used....
I see NO problem what so ever unless in setXXX(String s) you are creating a String Object using NEW operator.
http://plainoldjavaobject.blogspot.in
“The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'.”
http://plainoldjavaobject.blogspot.in
Rupesh Mhatre wrote:If these strings are getting created once in while its ok but still Nobody will recommend you this implementation. If you want your code to be more readable and easy to understand please make use of comments like
myBean.setName(message[1]); // name
myBean.setAddress(message[2]); // address
This will help code to be easily maintained.
It's just a flesh wound! Or a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|