File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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

Joined: Jan 10, 2002
Posts: 63857

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] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: using a getter to retrieve different parameters
It's not a secret anymore!