开发者

How can the documentation for Java's File.getAbsoluteFile() refer to "this" without context?

In the Java 1.6 documentation, the keyword "this" is employed without a context in the description of File.getAbsoluteFile(). See the "equivalent to" sentence. Fortunately, the getAbsolutePath() token is a link to documentation on a method of object File, so it is possible to开发者_JAVA百科 infer what is meant by "this". My question: Is following the link necessary to understand the context or is this an example of employing the "this" keyword in a way with which I am not familiar?

getAbsoluteFile

public File getAbsoluteFile() Returns the absolute form of this abstract pathname. Equivalent to new File(this.getAbsolutePath()).

Returns: The absolute abstract pathname denoting the same file or directory as this abstract pathname

Throws: SecurityException - If a required system property value cannot be accessed.

Since: 1.2


"this" is simply the File object you call the getAbsoluteFile() on. You have a File object that represents a file by its name, and you can make a new File object that represents the same file name, but by its absolute file path


'this' has the same meaning here that it has in the Java language itself. It refers to the instance of File on which the method is invoked. No 'context' or 'inference' required.


It appears that new File(this.getAbsolutePath()) should not be interpreted as being equivalent to invoking getAbsoluteFile(). Rather the documentation means that the implementation of getAbsoluteFile() is equivalent to return new File(this.getAbsolutePath()).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜