Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Parameter passing in methods  RSS feed

 
Aggarwal Arpit
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In code journalOrderString is defined as a String type.
journalOrderString = JournalUtil.getRecordedJournalOrder(scriptName + ".tst");
It is calling getRecordedJournalOrder()method from another class;
public static String getRecordedJournalOrder(String scriptName)
But here it is taking only scriptName as arguement and not scriptName + ".tst";

Can anybody explain?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
follow the links in this recent topic to discover your answer

http://www.coderanch.com/t/569326/java/java/when-arguments-parameters-return-exactly
 
Aggarwal Arpit
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael Dunn for your link.

But I want to know can we pass 2 values-(scriptName + ".tst");
to a method accepting only one argument -getRecordedJournalOrder(String scriptName),like we see in code.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arpit gmail wrote:Thanks Michael Dunn for your link.

But I want to know can we pass 2 values-(scriptName + ".tst");
to a method accepting only one argument -getRecordedJournalOrder(String scriptName),like we see in code.

Isn't it easier to try it out yourself? Did you? What happened? What do you think scriptName+".tst" evaluates to?
 
Aggarwal Arpit
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:
Arpit gmail wrote:Thanks Michael Dunn for your link
"Isn't it easier to try it out yourself? Did you? What happened? What do you think scriptName+".tst" evaluates to?"

It's working fine .But I want to know what does this mean scriptName+".tst"-It's appending .tst to scriptname?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> But I want to know can we pass 2 values-(scriptName + ".tst");

is it 2 values?

simple demo



are 2 values printed?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Recommended reading: String API, especially the part where it talks about concatenation
 
Aggarwal Arpit
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

I got the concept behind it:-)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!