• Post Reply Bookmark Topic Watch Topic
  • New Topic

Please explain this code  RSS feed

 
M sallu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • 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());
....
...
}
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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

 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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'.

 
Jim Hoglund
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
  • 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...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!