{"id":492,"date":"2025-10-05T19:32:36","date_gmt":"2025-10-05T10:32:36","guid":{"rendered":"https:\/\/software.satoshis.jp\/?p=492"},"modified":"2025-11-24T22:01:10","modified_gmt":"2025-11-24T13:01:10","slug":"%e7%b5%90%e5%90%88%e5%ba%a6%e3%82%92%e4%b8%8b%e3%81%92%e3%80%81%e5%87%9d%e9%9b%86%e5%ba%a6%e3%82%92%e4%b8%8a%e3%81%92%e3%82%8b-%e3%81%9d%e3%81%ae%e6%9c%80%e9%81%a9%e8%a7%a3%e3%81%af%e3%82%aa","status":"publish","type":"post","link":"https:\/\/software.satoshis.jp\/?p=492","title":{"rendered":"\u7d50\u5408\u5ea6\u3092\u4e0b\u3052\u3001\u51dd\u96c6\u5ea6\u3092\u4e0a\u3052\u308b - \u305d\u306e\u6700\u9069\u89e3\u306f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u306b\u3042\u3063\u305f"},"content":{"rendered":"<section id=\"intro\" style=\"border-top: none; padding-top: 20; margin-top: 0;\">\n<p class=\"lead\">\u300c\u4fee\u6b63\u3057\u305f\u3089\u5225\u306e\u5834\u6240\u3067\u30d0\u30b0\u304c\u51fa\u305f\uff01\u300d<\/p>\n<p class=\"lead\">\u300c\u30b3\u30fc\u30c9\u304c\u8907\u96d1\u3059\u304e\u3066\u3069\u3053\u3092\u76f4\u305b\u3070\u3044\u3044\u306e\u304b\u308f\u304b\u3089\u306a\u3044\uff01\u300d<\/p>\n<p class=\"lead\">\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3092\u958b\u767a\u3059\u308b\u3046\u3048\u3067\u3001\u305d\u306e\u3088\u3046\u306a\u7d4c\u9a13\u306f\u8ab0\u3057\u3082\u3042\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<p class=\"lead\">\u305d\u306e\u539f\u56e0\u306e\u591a\u304f\u306f<strong>\u7d50\u5408\u5ea6\u304c\u9ad8\u3044<\/strong>\u3001\u307e\u305f\u306f<strong>\u51dd\u96c6\u5ea6\u304c\u4f4e\u3044<\/strong>\u3001\u307e\u305f\u305d\u306e\u4e21\u65b9\u304c\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u5185\u90e8\u306b\u5b58\u5728\u3057\u3066\u3044\u308b\u3053\u3068\u306b\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u3089\u306f\u53e4\u304f\u304b\u3089\u8a2d\u8a08\u54c1\u8cea\u3092\u6e2c\u308b\u666e\u904d\u7684\u306a\u6307\u6a19\u3067\u3042\u308a\u3001\u73fe\u5b9f\u7684\u306b\u89e3\u6c7a\u3059\u308b\u6700\u9069\u89e3\u306e\u3072\u3068\u3064\u304c<strong>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411<\/strong>\u3067\u3059\u3002<\/p>\n<p>\u672c\u8a18\u4e8b\u3067\u306f\u3001<em>\u7d50\u5408\u5ea6\u3068\u51dd\u96c6\u5ea6\u306e\u57fa\u790e<\/em>\u304b\u3089\u59cb\u3081\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u306e\u57fa\u672c\u7684\u306a\u8003\u3048\u65b9\u3067\u3042\u308b<em>\u30ab\u30d7\u30bb\u30eb\u5316\u30fb\u60c5\u5831\u96a0\u853d\u30fb\u7d99\u627f\u30fb\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30ba\u30e0<\/em>\u304c\u54c1\u8cea\u306b\u3069\u3046\u52b9\u304f\u306e\u304b\u3001\u3055\u3089\u306b<strong>Comparator<\/strong>\u3092\u4f8b\u306b<strong>\u4ed5\u69d8\u3068\u5b9f\u88c5\u306e\u5206\u96e2<\/strong>\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<\/section>\n<div>\n<p><strong>\u76ee\u6b21<\/strong><\/p>\n<ol>\n<li><a href=\"#sec-basics\">\u7d50\u5408\u5ea6\u3068\u51dd\u96c6\u5ea6\u306e\u57fa\u790e\u3092\u7406\u89e3\u3059\u308b<\/a>\n<ol>\n<li><a href=\"#sec-coupling\">\u7d50\u5408\u5ea6\uff08Coupling\uff09\u3068\u306f<\/a><\/li>\n<li><a href=\"#sec-cohesion\">\u51dd\u96c6\u5ea6\uff08Cohesion\uff09\u3068\u306f<\/a><\/li>\n<li><a href=\"#sec-globals\">\u7d50\u5408\u5ea6\u306e\u6700\u60aa\u4f8b\uff1a\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u3068\u3044\u3046\u201c\u5168\u65b9\u4f4d\u4f9d\u5b58\u201d<\/a><\/li>\n<\/ol>\n<\/li>\n<li><a href=\"#sec-oo-principles\">\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u306e\u539f\u5247\u304c\u5c0e\u304f\u4f4e\u7d50\u5408\u30fb\u9ad8\u51dd\u96c6<\/a>\n<ol>\n<li><a href=\"#sec-encapsulation\">\u30ab\u30d7\u30bb\u30eb\u5316\uff08Encapsulation\uff09<\/a><\/li>\n<li><a href=\"#sec-info-hiding\">\u60c5\u5831\u96a0\u853d\uff08Information Hiding\uff09<\/a><\/li>\n<li><a href=\"#sec-inheritance\">\u7d99\u627f\uff08Inheritance\uff09<\/a><\/li>\n<li><a href=\"#sec-polymorphism\">\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30ba\u30e0\uff08Polymorphism\uff09<\/a><\/li>\n<\/ol>\n<\/li>\n<li><a href=\"#sec-comparator\">Comparator\u306b\u5b66\u3076\u300c\u4ed5\u69d8\u3068\u5b9f\u88c5\u306e\u5206\u96e2\u300d<\/a>\n<ol>\n<li><a href=\"#sec-spec-impl\">\u4ed5\u69d8\u306f\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3067\u3001\u5b9f\u88c5\u306f\u30af\u30e9\u30b9\u3067<\/a><\/li>\n<li><a href=\"#sec-file-examples\">java.io.File\u3092\u30bd\u30fc\u30c8\u3059\u308b\u5177\u4f53\u4f8b<\/a><\/li>\n<li><a href=\"#sec-explorer\">Windows\u30a8\u30af\u30b9\u30d7\u30ed\u30fc\u30e9\u306e\u4f8b\u3067\u7406\u89e3\u3059\u308b<\/a><\/li>\n<\/ol>\n<\/li>\n<li><a href=\"#sec-essence\">\u7d50\u5408\u5ea6\u30fb\u51dd\u96c6\u5ea6\u304b\u3089\u898b\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u306e\u672c\u8cea<\/a><\/li>\n<li><a href=\"#sec-summary\">\u307e\u3068\u3081<\/a><\/li>\n<\/ol>\n<\/div>\n<section id=\"sec-basics\">\n<h2>1. \u7d50\u5408\u5ea6\u3068\u51dd\u96c6\u5ea6\u306e\u57fa\u790e\u3092\u7406\u89e3\u3059\u308b<\/h2>\n<h3 id=\"sec-coupling\">\u7d50\u5408\u5ea6\uff08Coupling\uff09\u3068\u306f<\/h3>\n<p>\u7d50\u5408\u5ea6\u306f<strong>\u30e2\u30b8\u30e5\u30fc\u30eb\u540c\u58eb\u306e\u4f9d\u5b58\u306e\u5f37\u3055<\/strong>\u3092\u793a\u3059\u6307\u6a19\u3067\u3059\u3002\u3042\u308b\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u4ed6\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5185\u90e8\u5b9f\u88c5\u306b\u5f37\u304f\u4f9d\u5b58\u3057\u3066\u3044\u308b\u5834\u5408\u3001\u305d\u308c\u3089\u306f\u300c\u7d50\u5408\u5ea6\u304c\u9ad8\u3044\u300d\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u9ad8\u7d50\u5408\uff1a1\u3064\u306e\u5909\u66f4\u304c\u4ed6\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u6ce2\u53ca\u3057\u3084\u3059\u3044<\/li>\n<li>\u4f4e\u7d50\u5408\uff1a\u5909\u66f4\u306e\u5f71\u97ff\u7bc4\u56f2\u304c\u5c40\u6240\u5316\u3055\u308c\u308b<\/li>\n<\/ul>\n<p>\u7406\u60f3\u7684\u306b\u306f\u3001\u30e2\u30b8\u30e5\u30fc\u30eb\u9593\u306e\u4f9d\u5b58\u95a2\u4fc2\u3092\u5c11\u306a\u304f\u3001\u53ef\u80fd\u306a\u3089\u3070\u30bc\u30ed\u306b\u3059\u308b\u3053\u3068\u3067\u3059\u3002<strong>\u7d50\u5408\u5ea6<\/strong>\u3092\u5c11\u306a\u304f\u3059\u308b\u3053\u3068\u3067\u4fdd\u5b88\u6027\u30fb\u62e1\u5f35\u6027\u30fb\u30c6\u30b9\u30c8\u5bb9\u6613\u6027\u304c\u9ad8\u307e\u308a\u307e\u3059\u3002<\/p>\n<h3 id=\"sec-cohesion\">\u51dd\u96c6\u5ea6\uff08Cohesion\uff09\u3068\u306f<\/h3>\n<p>\u51dd\u96c6\u5ea6\u306f<strong>\u30e2\u30b8\u30e5\u30fc\u30eb\u5185\u90e8\u306e\u8981\u7d20\u306e\u95a2\u9023\u306e\u5f37\u3055<\/strong>\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u4f4e\u51dd\u96c6\uff1a1\u3064\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u95a2\u9023\u6027\u304c\u4f4e\u3044\u8907\u6570\u306e\u60c5\u5831\u304c\u6df7\u5728\u3057\u3066\u3044\u308b\u72b6\u614b<\/li>\n<li>\u9ad8\u51dd\u96c6\uff1a1\u3064\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u95a2\u9023\u6027\u304c\u9ad8\u3044\u60c5\u5831\u3060\u3051\u304c\u96c6\u307e\u3063\u3066\u3044\u308b\u72b6\u614b<\/li>\n<\/ul>\n<p>\u5358\u4e00\u8cac\u4efb\u306e\u539f\u5247\uff08SRP\uff09\u3068\u3082\u76f4\u7d50\u3057\u3001\u7406\u60f3\u306f<strong>\u51dd\u96c6\u5ea6<\/strong>\u304c\u9ad8\u3044\u72b6\u614b\u3067\u3059\u3002<\/p>\n<h3 id=\"sec-globals\">\u7d50\u5408\u5ea6\u306e\u6700\u60aa\u4f8b\uff1a\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u3068\u3044\u3046\u201c\u5168\u65b9\u4f4d\u4f9d\u5b58\u201d<\/h3>\n<p>\u6700\u60aa\u306e\u4f8b\u3068\u3057\u3066\u306f<strong>\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570<\/strong>\u304c\u6319\u3052\u3089\u308c\u307e\u3059\u3002\u3069\u3053\u304b\u3089\u3067\u3082\u7121\u5236\u9650\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u306e\u3067\u3001\u3059\u3079\u3066\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u4f9d\u5b58\u3057\u3066\u3044\u308b\u72b6\u614b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npublic class Globals {\r\n    public static int sortMode = 0; \/\/ 0: name, 1: date, 2: size\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u8907\u6570\u306e\u30af\u30e9\u30b9\u304c <code>Globals.sortMode<\/code> \u306b\u4f9d\u5b58\u3059\u308b\u3068\u3001\u3069\u3053\u304b\u3067\u5024\u3092\u5909\u3048\u305f\u77ac\u9593\u306b\u3001\u305d\u308c\u3092\u53c2\u7167\u3057\u3066\u3044\u308b\u7b87\u6240\u306e\u6319\u52d5\u304c\u5909\u308f\u308a\u307e\u3059\u3002\u4fee\u6b63\u306e\u6ce2\u53ca\u3001\u30c6\u30b9\u30c8\u306e\u4e0d\u5b89\u5b9a\u5316\u3001\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u304c\u5b58\u5728\u3059\u308b\u3053\u3068\u306b\u3088\u308a\u3001\u8cac\u4efb\u306e\u6240\u5728\u4e0d\u660e\u306a\u3069\u306e\u591a\u6570\u306e\u554f\u984c\u304c\u767a\u751f\u3057\u307e\u3059\u3002\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u306f\u300c\u9ad8\u7d50\u5408\u30fb\u4f4e\u51dd\u96c6\u300d\u306e\u8c61\u5fb4\u3067\u3059\u3002<\/p>\n<p>\u7d50\u5408\u5ea6\u3092\u4f4e\u304f\u3059\u308b\u7b2c\u4e00\u6b69\u306f<b>\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570<\/b>\u3092\u6392\u9664\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<\/section>\n<section id=\"sec-oo-principles\">\n<h2>2. \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u306e\u539f\u5247\u304c\u5c0e\u304f\u4f4e\u7d50\u5408\u30fb\u9ad8\u51dd\u96c6<\/h2>\n<h3 id=\"sec-encapsulation\">\u30ab\u30d7\u30bb\u30eb\u5316\uff08Encapsulation\uff09<\/h3>\n<p>\u30c7\u30fc\u30bf\u3068\u305d\u308c\u3092\u64cd\u4f5c\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3092\u3072\u3068\u307e\u3068\u3081\u306b\u3057\u3001\u5916\u90e8\u304b\u3089\u76f4\u63a5\u72b6\u614b\u3092\u89e6\u3089\u305b\u306a\u3044\u3053\u3068\u3067\u3001\u5916\u90e8\u4f9d\u5b58\u3092\u6e1b\u3089\u3057\uff08\u4f4e\u7d50\u5408\uff09\u3001\u5185\u90e8\u6574\u5408\u6027\u3092\u5b88\u308a\u307e\u3059\uff08\u9ad8\u51dd\u96c6\uff09\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u53e3\u5ea7\uff08Account\uff09\u3068\u3044\u3046\u30af\u30e9\u30b9\u3067\u306f\u3001\u5916\u90e8\u304b\u3089\u6b8b\u9ad8\uff08balance\uff09\u306b\u5bfe\u3059\u308b\u76f4\u63a5\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u3092\u4e0d\u53ef\u80fd\u306b\u3057\u3001\u30e1\u30bd\u30c3\u30c9\u7d4c\u7531\u3067\u306e\u307f\u5909\u66f4\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u3053\u3068\u3067\u3001\u6b8b\u9ad8\u3092\u4e0d\u6b63\u306b\u5909\u66f4\u3067\u304d\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npublic class Account {\r\n    private int balance;\r\n\r\n    public void deposit(int amount) {\r\n        this.balance += amount;\r\n    }\r\n    public void withdraw(int amount) {\r\n        if (amount &amp;lt;= balance) balance -= amount;\r\n    }\r\n    public void getBalance() {\r\n        return balance;\r\n    }\r\n}\r\n<\/pre>\n<h3 id=\"sec-info-hiding\">\u60c5\u5831\u96a0\u853d\uff08Information Hiding\uff09<\/h3>\n<p>Account\u30af\u30e9\u30b9\u306fbalance\u3092\u30af\u30e9\u30b9\u306e\u5185\u90e8\u306b\u96a0\u853d\u3059\u308b\u3053\u3068\u3067\u3001\u4e0d\u6b63\u306a\u5909\u66f4\u3092\u9632\u6b62\u3057\u307e\u3059\u3002<\/p>\n<p>\u5916\u90e8\u306f\u300c\u4f55\u304c\u3067\u304d\u308b\u304b\u300d\u3060\u3051\u3092\u77e5\u308a\u3001\u300c\u3069\u3046\u5b9f\u73fe\u3057\u3066\u3044\u308b\u304b\u300d\u306f\u77e5\u3089\u306a\u3044\u3002\u5b9f\u88c5\u3092\u5909\u3048\u3066\u3082\u547c\u3073\u51fa\u3057\u5074\u306b\u5f71\u97ff\u3057\u306a\u3044\u305f\u3081\u3001\u4f4e\u7d50\u5408\u3092\u4fdd\u3066\u307e\u3059\u3002<\/p>\n<h3 id=\"sec-inheritance\">\u7d99\u627f\uff08Inheritance\uff09<\/h3>\n<p>\u518d\u5229\u7528\u306e\u624b\u6bb5\u3067\u3059\u304c\u3001\u89aa\u30af\u30e9\u30b9\u3078\u306e\u5f37\u3044\u4f9d\u5b58\u3092\u751f\u3080\u305f\u3081\u614e\u91cd\u306b\u8003\u616e\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u5909\u66f4\u306e\u5f71\u97ff\u306e\u6ce2\u53ca\u3092\u907f\u3051\u308b\u305f\u3081\u3001\u8fd1\u5e74\u306f<strong>\u7d99\u627f\u3088\u308a\u59d4\u8b72<\/strong>\uff08Composition over Inheritance\uff09\u304c\u63a8\u5968\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3 id=\"sec-polymorphism\">\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30ba\u30e0\uff08Polymorphism\uff09<\/h3>\n<p>\u540c\u3058\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3067\u7570\u306a\u308b\u5b9f\u88c5\u3092\u6271\u3046\u4ed5\u7d44\u307f\u3002\u547c\u3073\u51fa\u3057\u5074\u306f\u5177\u8c61\u3092\u77e5\u3089\u305a\u306b\u5229\u7528\u3067\u304d\u3001\u5b9f\u88c5\u5074\u306f\u8cac\u52d9\u306b\u96c6\u4e2d\u3067\u304d\u307e\u3059\u3002\u4f4e\u7d50\u5408\u30fb\u9ad8\u51dd\u96c6\u306e\u4e2d\u6838\u3067\u3059\u3002<\/p>\n<\/section>\n<section id=\"sec-comparator\">\n<h2>3. Comparator\u306b\u5b66\u3076\u300c\u4ed5\u69d8\u3068\u5b9f\u88c5\u306e\u5206\u96e2\u300d<\/h2>\n<h3 id=\"sec-spec-impl\">\u4ed5\u69d8\u306f\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3067\u3001\u5b9f\u88c5\u306f\u30af\u30e9\u30b9\u3067<\/h3>\n<p><code>Comparator&lt;T&gt;<\/code> \u306f\u300c2\u3064\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u3069\u3046\u6bd4\u8f03\u3059\u308b\u304b\u300d\u3068\u3044\u3046<strong>\u4ed5\u69d8<\/strong>\u306e\u307f\u3092\u5b9a\u7fa9\u3057\u3001\u5b9f\u969b\u306e\u30ed\u30b8\u30c3\u30af\u306f\u500b\u5225\u306e\u30af\u30e9\u30b9\u306b\u5207\u308a\u51fa\u305b\u307e\u3059\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npublic interface Comparator&lt;T&gt; {\r\n    int compare(T a, T b);\r\n}\r\n<\/pre>\n<h3 id=\"sec-file-examples\">java.io.File\u3092\u30bd\u30fc\u30c8\u3059\u308b\u5177\u4f53\u4f8b<\/h3>\n<p><code>java.io.File<\/code> \u306f\u540d\u524d\u30fb\u30b5\u30a4\u30ba\u30fb\u66f4\u65b0\u65e5\u6642\u3092\u5099\u3048\u3001Comparator\u306e\u6559\u6750\u306b\u6700\u9069\u3067\u3059\u3002<\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u540d\u3001\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u3001\u66f4\u65b0\u65e5\u6642\u3067\u30bd\u30fc\u30c8\u3059\u308b\u305f\u3081\u306eComparator\u3092\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u540d\u3067\u6bd4\u8f03\u3059\u308bComparator\u3068\u3057\u3066FilenameComparator\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nimport java.io.File;\r\nimport java.util.Comparator;\r\n\r\npublic class FilenameComparator implements Comparator&lt;File&gt; {\r\n    public int compare(File a, File b) {\r\n        return a.getName().compareTo(b.getName());\r\n    }\r\n}\r\n<\/pre>\n<pre>\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u3067\u6bd4\u8f03\u3059\u308bComparator\u3068\u3057\u3066FilesizeComparator\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\r\n\r\n<\/pre>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nimport java.io.File;\r\nimport java.util.Comparator;\r\n\r\npublic class FilesizeComparator implements Comparator&lt;File&gt; {\r\n    public int compare(File a, File b) {\r\n        return Long.compare(a.length(), b.length());\r\n    }\r\n}\r\n<\/pre>\n<pre>\u66f4\u65b0\u65e5\u6642\u3067\u6bd4\u8f03\u3059\u308bComparator\u3068\u3057\u3066UpdateTimeComparator\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\r\n\r\n<\/pre>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nimport java.io.File;\r\nimport java.util.Comparator;\r\n\r\npublic class UpdateTimeComparator implements Comparator&lt;File&gt; {\r\n    public int compare(File a, File b) {\r\n        return Long.compare(a.lastModified(), b.lastModified());\r\n    }\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u4f5c\u6210\u3057\u305f\u5404Comparator\u3092\u4f7f\u7528\u3057\u3066\u30bd\u30fc\u30c8\u3059\u308b\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>sort()\u30e1\u30bd\u30c3\u30c9\u306b\u6e21\u3059Comparator\u3092\u5909\u66f4\u3059\u308b\u3060\u3051\u3067\u30bd\u30fc\u30c8\u9806\u3092\u5909\u66f4\u3067\u304d\u307e\u3059\u3002sort()\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u6e21\u3055\u308c\u305fComparator\u306e\u4ed5\u69d8\u3060\u3051\u3092\u8a8d\u8b58\u3057\u3066\u3044\u3066\u3001\u5b9f\u88c5\u306b\u306f\u4e00\u5207\u4f9d\u5b58\u3057\u3066\u3044\u306a\u3044\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nimport java.io.File;\r\nimport java.util.*;\r\n\r\nList&lt;File&gt; files = List.of(new File(&quot;a.txt&quot;), new File(&quot;b.txt&quot;), new File(&quot;c.txt&quot;));\r\n\r\nfiles.sort(new FilenameComparator());   \/\/ \u30d5\u30a1\u30a4\u30eb\u540d\u9806\r\nfiles.sort(new FilesizeComparator());   \/\/ \u30b5\u30a4\u30ba\u9806\r\nfiles.sort(new UpdateTimeComparator()); \/\/ \u66f4\u65b0\u65e5\u6642\u9806\r\n<\/pre>\n<pre><\/pre>\n<h3 id=\"sec-explorer\">Windows\u30a8\u30af\u30b9\u30d7\u30ed\u30fc\u30e9\u306e\u4f8b\u3067\u7406\u89e3\u3059\u308b<\/h3>\n<p>Windows\u306e\u30a8\u30af\u30b9\u30d7\u30ed\u30fc\u30e9\u306e\u8a73\u7d30\u8868\u793a\u3067\u300c\u540d\u524d\u9806\u300d\u300c\u30b5\u30a4\u30ba\u9806\u300d\u300c\u66f4\u65b0\u65e5\u9806\u300d\u306b\u4e26\u3073\u66ff\u3048\u3089\u308c\u308b\u306e\u306f\u3001\u307e\u3055\u306b\u3053\u306e\u767a\u60f3\u3067\u3059\u3002<\/p>\n<p>\u30bd\u30fc\u30c8\u6a5f\u80fd\u81ea\u4f53\uff08\u547c\u3073\u51fa\u3057\u5074\uff09\u306f\u6bd4\u8f03\u65b9\u6cd5\uff08\u5b9f\u88c5\uff09\u3092\u77e5\u3089\u305a\u3001\u5404Comparator\u306f\u6bd4\u8f03\u3068\u3044\u3046\u8cac\u52d9\u306b\u96c6\u4e2d\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u7d50\u679c\u3068\u3057\u3066\u3001\u547c\u3073\u51fa\u3057\u5074\u306f<strong>\u4ed5\u69d8<\/strong>\u306b\u306e\u307f\u4f9d\u5b58\uff08\u4f4e\u3044\u7d50\u5408\u5ea6\uff09\u3001\u5404\u5b9f\u88c5\u306f<strong>\u8cac\u52d9\u96c6\u4e2d<\/strong>\uff08\u9ad8\u3044\u51dd\u96c6\u5ea6\uff09\u3092\u9054\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u3055\u3089\u306b\u3001\u30a8\u30af\u30b9\u30d7\u30ed\u30fc\u30e9\u3067\u306f\u5927\u304d\u3044\u30a2\u30a4\u30b3\u30f3\u3084\u5c0f\u3055\u3044\u30a2\u30a4\u30b3\u30f3\u306a\u3069\u306e\u8868\u793a\u65b9\u5f0f\u3092\u5207\u308a\u66ff\u3048\u308b\u6a5f\u80fd\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u306f\u3001\u30bd\u30fc\u30c8\u3068\u540c\u69d8\u306e\u3084\u308a\u304b\u305f\u3067\u3001\u8868\u793a\u3059\u308b\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3092\u5207\u308a\u66ff\u3048\u308b\u3088\u3046\u306b\u4f5c\u3089\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<\/section>\n<section id=\"sec-essence\">\n<h2>4. \u7d50\u5408\u5ea6\u30fb\u51dd\u96c6\u5ea6\u304b\u3089\u898b\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u306e\u672c\u8cea<\/h2>\n<p>\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u306f\u201c\u5168\u65b9\u4f4d\u4f9d\u5b58\u201d\u3002\u5bfe\u3057\u3066\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u306f\u300c\u4f9d\u5b58\u3092\u5236\u5fa1\u3057\u3001\u8cac\u52d9\u3092\u9589\u3058\u8fbc\u3081\u308b\u300d\u4ed5\u7d44\u307f\u3067\u3059\u3002<\/p>\n<p>\u6bd4\u8f03\u3068\u3044\u3046\u5171\u901a\u4ed5\u69d8\u3092\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3068\u3057\u3066\u5b9a\u7fa9\u3057\u3001\u5404\u6226\u7565\u3092\u72ec\u7acb\u5b9f\u88c5\u306b\u5206\u96e2\u3059\u308c\u3070\u3001\u547c\u3073\u51fa\u3057\u5074\u3092\u5909\u3048\u305a\u306b\u62e1\u5f35\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3053\u305d<strong>\u4f4e\u7d50\u5408\u30fb\u9ad8\u51dd\u96c6<\/strong>\u306e\u5b9f\u8df5\u3067\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<\/section>\n<section id=\"sec-summary\">\n<h2>5. \u307e\u3068\u3081<\/h2>\n<table style=\"width: 100%; border-collapse: collapse; border: 1px solid var(--bd);\">\n<thead>\n<tr style=\"background: #f3f4f6;\">\n<th style=\"text-align: left; padding: .5rem; border: 1px solid var(--bd);\">\u89b3\u70b9<\/th>\n<th style=\"text-align: left; padding: .5rem; border: 1px solid var(--bd);\">\u60aa\u3044\u4f8b<\/th>\n<th style=\"text-align: left; padding: .5rem; border: 1px solid var(--bd);\">\u826f\u3044\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding: .5rem; border: 1px solid var(--bd);\">\u7d50\u5408\u5ea6<\/td>\n<td style=\"padding: .5rem; border: 1px solid var(--bd);\">\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u306b\u4f9d\u5b58<\/td>\n<td style=\"padding: .5rem; border: 1px solid var(--bd);\">\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306b\u4f9d\u5b58\uff08Comparator\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: .5rem; border: 1px solid var(--bd);\">\u51dd\u96c6\u5ea6<\/td>\n<td style=\"padding: .5rem; border: 1px solid var(--bd);\">\u8cac\u52d9\u304c\u66d6\u6627\u306a\u30af\u30e9\u30b9<\/td>\n<td style=\"padding: .5rem; border: 1px solid var(--bd);\">\u660e\u78ba\u306a\u8cac\u52d9\u3092\u6301\u3064\u30af\u30e9\u30b9<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: .5rem; border: 1px solid var(--bd);\">\u62e1\u5f35\u6027<\/td>\n<td style=\"padding: .5rem; border: 1px solid var(--bd);\">\u30b3\u30fc\u30c9\u306e\u3042\u3061\u3053\u3061\u3067\u4fee\u6b63\u304c\u5fc5\u8981<\/td>\n<td style=\"padding: .5rem; border: 1px solid var(--bd);\">\u65b0\u3057\u3044Comparator\u3092\u8ffd\u52a0\u3059\u308b\u3060\u3051<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: .5rem; border: 1px solid var(--bd);\">\u8a2d\u8a08\u601d\u60f3<\/td>\n<td style=\"padding: .5rem; border: 1px solid var(--bd);\">\u72b6\u614b\u3068\u5b9f\u88c5\u304c\u6df7\u5728<\/td>\n<td style=\"padding: .5rem; border: 1px solid var(--bd);\">\u4ed5\u69d8\u3068\u5b9f\u88c5\u304c\u5206\u96e2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u306f\u76ee\u7684\u3067\u306f\u306a\u304f\u624b\u6bb5\u3067\u3059\u3002<\/p>\n<p>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u3067\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3092\u8a2d\u8a08\u3059\u308b\u3053\u3068\u3067\u3001<strong>\u7d50\u5408\u5ea6\u3092\u4e0b\u3052\u3001\u51dd\u96c6\u5ea6\u3092\u4e0a\u3052\u308b<\/strong>\u3053\u3068\u304c\u5bb9\u6613\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u300c\u4fee\u6b63\u3057\u305f\u3089\u5225\u306e\u5834\u6240\u3067\u30d0\u30b0\u304c\u51fa\u305f\uff01\u300d \u300c\u30b3\u30fc\u30c9\u304c\u8907\u96d1\u3059\u304e\u3066\u3069\u3053\u3092\u76f4\u305b\u3070\u3044\u3044\u306e\u304b\u308f\u304b\u3089\u306a\u3044\uff01\u300d \u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3092\u958b\u767a\u3059\u308b\u3046\u3048\u3067\u3001\u305d\u306e\u3088\u3046\u306a\u7d4c\u9a13\u306f\u8ab0\u3057\u3082\u3042\u308b\u306f\u305a\u3067\u3059\u3002 \u305d\u306e\u539f\u56e0\u306e\u591a\u304f\u306f\u7d50\u5408\u5ea6\u304c\u9ad8\u3044\u3001\u307e\u305f\u306f\u51dd &#8230; <\/p>\n","protected":false},"author":1,"featured_media":493,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71,175],"tags":[185,186,188,182,177,187,184,183],"class_list":["post-492","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-175","tag-cohesion","tag-coupling","tag-188","tag-182","tag-177","tag-187","tag-184","tag-183"],"nelio_content":{"autoShareEndMode":"never","automationSources":{"useCustomSentences":false,"customSentences":[]},"efiAlt":"","efiUrl":"","followers":[1],"highlights":[],"isAutoShareEnabled":true,"networkImageIds":[],"permalinkQueryArgs":[],"series":[],"suggestedReferences":[]},"views":407,"_links":{"self":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/492","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=492"}],"version-history":[{"count":14,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/492\/revisions"}],"predecessor-version":[{"id":513,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/492\/revisions\/513"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/media\/493"}],"wp:attachment":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}