• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

to get sting value into object

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have one String 'DETAILS' and I want to pass this string as Order class' object. i.e.



how can I pass 'DETAILS' to the getOrder method ?
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused. Do you want the String to become an Order? Or a property of Order?
Or this:
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's hard to answer this question, because we don't know what your Order and WestOrder classes look like, and what the DETAILS string contains. A String is a totally different kind of object than an Order or a WestOrder. It sounds like this:


Trying to fit a square peg in a round hole

There is no generic way to pass a String to a method that takes a different kind of object. Does the DETAILS string contain information on an order? What does it look like? Maybe you need to parse the string, make an Order object and set the fields of that object using information found in the string?
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then you'll need a constructor/method that accepts a String and returns a WestOrder

But I would really recommend you to read some tutorials about object orientation and java.
 
Bartender
Posts: 1849
15
Eclipse IDE Spring VI Editor Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
uhm.... why not just add an additional parameter? Ahh I guess it doesn't matter.

What you need to do is first associate the string with the WestOrder. Something like this (and forgive me cause I don't have a lot of your code to work with):



Then when you send the WestOrder to the setOrder, you can get the details out like this:



Does that help?
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic