[英]Passing parameter to class property in Java
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. "
NET 2008中,除了get和set属性外,该属性还有一个名为“ 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? 在Java代码中这等效吗?
to use I do the following: 使用时,请执行以下操作:
oClass.UpdateField("NEW") = 1850
I have this code in java 我在java中有这段代码
public void setUpdateField(String idField) {
this.idField = idField;
}
public String getUpdateField() {
return idField;
}
but I need to put the parameter "pParam" 但我需要输入参数“ pParam”
Thanks in advance. 提前致谢。
What you've got in the .NET code is an indexer in C# terms. .NET代码中提供的内容是C#中的索引器 。 There's no equivalent in Java - you'll just need to take two parameters:
Java没有等效功能-您只需要使用两个参数即可:
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... 坦白地说,.NET中的“ getter”似乎没有使用索引有点奇怪。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.