This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to modify method parameters?

 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I am having a method which takes a couple of strings as parameters. The class which uses this method may sometimes send null parameters. In my method I am checking the parameter values. If any of the parameter is null I am assigning some value to it.

When I use the sonar plugin it reports that "Assignment of parameter x is not allowed". What is the right approach to assign a value to a method parameter?

Can anyone please tell me? Thank you all in advance. Good day.
 
Winston Gutkowski
Bartender
Pie
Posts: 9477
50
Eclipse IDE Hibernate Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chaitanya karthikk wrote:Hi all, I am having a method which takes a couple of strings as parameters. The class which uses this method may sometimes send null parameters. In my method I am checking the parameter values. If any of the parameter is null I am assigning some value to it.

When I use the sonar plugin it reports that "Assignment of parameter x is not allowed". What is the right approach to assign a value to a method parameter?

Can anyone please tell me? Thank you all in advance. Good day.

Without seeing the code, it's very hard to tell. Please supply an SSCCE.

Winston
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:
Without seeing the code, it's very hard to tell. Please supply an SSCCE.
Winston
Hi Winston, thanks for the reply. This is the code

Now I understood why I should not change the parameter directly, because it messes up the things/code. Now I replace the above code with
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chaitanya, Winston gave you that link for a reason. Is it really too much trouble click the link and go through that page?
 
Campbell Ritchie
Sheriff
Pie
Posts: 47274
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chaitanya karthikk wrote: . . . I should not change the parameter directly, because it messes up the things/code. . . .
No, it doesn’t. It doesn’t mess anything up. To find out what it actually does, have a look at this thread, which refers back to our pass‑by‑value story.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic