• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Sax Parsing startElement() method automatically create different object to avoid overwrite variable

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i cant understand the problem regarding when following startElement method is called then it's start to read from< laptop> tag and crate object Laptop laptop1=new Laptop() and set the value into endElement method to Bean class. but what hapeen in Line 1 I marked at below means second <Lenovo> tag it's reached to read. the Another Different object must be crated i.e Laptop laptop2=new Laptop() to avoid over wright variable value. thanks in advance.

-->> Laptop.xml


 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think line 7 should read "laptop = new Laptop()" instead of "laptop1 = new Laptop()" - you're not using "laptop1" anywhere else.
 
Squanch that. And squanch this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!