如何获取 argument.nameOfTheMethod() 中参数的值?
How do I get the value of the argument in argument.nameOfTheMethod()?
如何获取Argument的值来实现这样的方法。 argument.nameOfTheMethod()
。
我想在这个参数上使用一个条件来编写这个方法的代码。
例如:
"foo".charAt()
charAt
如何访问"foo"
的值?
"foo".CharAt()
How does charAt
access the value of "foo"
?
charAt
通过方法内部的 this
引用访问值 "foo"
。
调用 obj.method()
时,您可以将 obj
视为名称为 this
的隐式参数。在 Java 8 中,您甚至可以在方法签名中将其显式显示如下:
class SomeClass {
public void someMethod(SomeClass this) {
// ...
}
}
这是一个很好的起点:The Java™ Tutorials: Using the this
Keyword。
如何获取Argument的值来实现这样的方法。 argument.nameOfTheMethod()
。
我想在这个参数上使用一个条件来编写这个方法的代码。
例如:
"foo".charAt()
charAt
如何访问"foo"
的值?
"foo".CharAt()
How doescharAt
access the value of"foo"
?
charAt
通过方法内部的 this
引用访问值 "foo"
。
调用 obj.method()
时,您可以将 obj
视为名称为 this
的隐式参数。在 Java 8 中,您甚至可以在方法签名中将其显式显示如下:
class SomeClass {
public void someMethod(SomeClass this) {
// ...
}
}
这是一个很好的起点:The Java™ Tutorials: Using the this
Keyword。