Java中向类属性传递参数
我在视觉基础类中有这个属性。 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
这相当于 java 代码中的参数吗?
要使用我执行以下操作:
oClass.UpdateField("NEW") = 1850
我在 java 中有此代码
public void setUpdateField(String idField) {
this.idField = idField;
}
public String getUpdateField() {
return idField;
}
,但我需要放置参数“pParam”
提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用 C# 术语来说,.NET 代码中的内容是一个索引器。 Java 中没有类似的东西 - 你只需要接受两个参数:
坦率地说,我认为 .NET 中的“getter”似乎不使用索引,这有点奇怪......
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:
Frankly I think it's a little odd that the "getter" in .NET doesn't seem to use the index...