aspose file tools*
The moose likes Beginning Java and the fly likes using a getter to retrieve different parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "using a getter to retrieve different parameters" Watch "using a getter to retrieve different parameters" New topic
Author

using a getter to retrieve different parameters

Ben Hultin
Ranch Hand

Joined: Aug 17, 2009
Posts: 135
I am creating a program where I need to pass different parameters into a single getter and have it print out different valaues based on the paramter.

So far I have one string which I used substrings to divide the string into different chunks then convert them to ints. so now I need to assign these different ints to paramter numbers which would be passed through to the getter for printing.




this is how the different values would be passed into the getter:



Any suggestions on how I could accomplish this?

Thanks a lot for the help
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Ben Hultin wrote:


i Assume IpAddress is a Constructor .

there are 2 ways to accomplish this task.
one way is provide getter/setter for octet1,octet2,octet3,octet4 . an another way is wrap the values into a single int Array and provide getter/setter .

Hope this helps
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61222
    
  66

By the way, if you're passing a parameter into a "getter", then by definition, it isn't a "getter".

(Unless you start contemplating indexed properties -- but there are strict rules that must be followed there as well.)


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
wood burning stoves
 
subject: using a getter to retrieve different parameters