0

I have this property in a visual basic class. NET 2008, the property in addition to the get and set has a parameter called "pParam. "

Public Property UpdateField(ByVal pParam As String) As String
        Get
            Return Me.idField
        End Get
        Set(ByVal value As String)
            Me.idField = value
            If pParam = "NEW" Then
        // some code here
            End If
        End Set
End Property

which is the equivalent of this in java code?

to use I do the following:

oClass.UpdateField("NEW") = 1850

I have this code in java

public void setUpdateField(String idField) {
    this.idField = idField;
}
public String getUpdateField() {
    return idField;
}

but I need to put the parameter "pParam"

Thanks in advance.

seba123neo
  • 4,688
  • 10
  • 35
  • 53
  • What are you trying to do with pParam? Isn't it just asking in set if the field equals some value? So you could just do `if (idField.equals("NEW"))`? – Cheryl Simon Feb 07 '11 at 22:10

1 Answers1

1

What you've got in the .NET code is an indexer in C# terms. There's no equivalent in Java - you'll just need to take two parameters:

public void setUpdateField(String idField, String pParam) {
    ...
}

Frankly I think it's a little odd that the "getter" in .NET doesn't seem to use the index...

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194