• 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

Please explain this code

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please try to explain the below code. I am sure most of people here need to know the basics. So instead of referring to any links, appreciate if you could explain

What does this code mean

public CheckingResponse checking( CheckingRequest checkingRequest ) {
//I think this means we are creating a CheckingResponse method and checking as its object which will take input from CheckingRequest method's checkingRequest object. Am i right here??

//then what is this -----------V---------- //why create new object when checking is already present??
CheckingResponse checkingResponse=new CheckingResponse();


//and what does this line mean?
IdTables idTables=checkingDao.findById(checkingRequest.getId());
....
...
}
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

M sallu wrote:
public CheckingResponse checking( CheckingRequest checkingRequest ) {
//I think this means we are creating a CheckingResponse method and checking as its object which will take input from CheckingRequest method's checkingRequest object. Am i right here??



Hmmm.... I think it may be a good idea to go back and reread the section of your book on methods.... because you are pretty far from the mark. It is better to start again than to guess at this point.

No, you are not creating a CheckingResponse method. No, you are not creating a checking object. And I am not sure what you mean by "CheckingRequets method's checkingRequest object".

M sallu wrote:
//then what is this -----------V---------- //why create new object when checking is already present??
CheckingResponse checkingResponse=new CheckingResponse();



Not sure what you mean here. But there is no checking object -- as mentioned.

Henry

 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as "Am I right here???", I think the answer is most definitely "no", your explanations aren't right.

The first line says


Let's define a method named 'checking.' This method will take one parameter, a CheckingRequest object, which we'll refer to as 'checkingRequest' in the body of the method. The method will return a CheckingResponse object.



The second line says


Let's have a variable named 'checkingResponse' which is defined to hold a CheckingResponse object, and furthermore, let's create a new CheckingResponse object and have the variable hold it.



The third line says


Call the method "getId()" on the CheckingRequest object in the variable "checkingRequest", and keep the result in temporary storage.
I have some kind of object in a variable named "checkingDao". Call that object's method named "findById", and pass the earlier result from temporary storage as its argument. The result will be an object of type IdTables; store it in a new variable named 'idTables'.


 
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would help to know the context of your questions. Please
describe the problem you are trying to solve.

Jim...
 
Anderson gave himself the promotion. So I gave myself this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic