Why do some folks use Class#method instead of Class.method in correspondence?

前端 未结 1 1594
盖世英雄少女心
盖世英雄少女心 2021-01-01 10:02

When writing about methods in Java (i.e. in forums, mailing lists, issue trackers, etc.) many people separate the method name from the class name using the \'#\' symbol inst

相关标签:
1条回答
  • 2021-01-01 10:51

    It's the notation used in javadoc comments when linking to another class' method.

    EDIT

    To gather the additional information provided in comments:

    • @Hugo notes that the # notation in turn comes from HTML anchors
    • @maksimov points out that Object.method is the Java syntax to call static methods, which could be misleading

    UPDATE

    Java 8 brings a new syntax for method references, which now seems to become more popular - so Object#toString tends to now be written Object::toString.

    0 讨论(0)
提交回复
热议问题