{"id":73441,"date":"2024-08-14T20:34:23","date_gmt":"2024-08-14T17:04:23","guid":{"rendered":"https:\/\/nabfollower.com\/blog\/exploring-the-power-of-pattern-matching-with-switch-in-java-21-506a\/"},"modified":"2024-08-14T20:34:23","modified_gmt":"2024-08-14T17:04:23","slug":"exploring-the-power-of-pattern-matching-with-switch-in-java-21-506a","status":"publish","type":"post","link":"https:\/\/nabfollower.com\/blog\/exploring-the-power-of-pattern-matching-with-switch-in-java-21-506a\/","title":{"rendered":"\u0628\u0631\u0631\u0633\u06cc \u0642\u062f\u0631\u062a \u062a\u0637\u0628\u06cc\u0642 \u0627\u0644\u06af\u0648 \u0628\u0627 \u0633\u0648\u0626\u06cc\u0686 \u062f\u0631 \u062c\u0627\u0648\u0627 21"},"content":{"rendered":"<p>Summarize this content to 400 words in Persian Lang \u06cc\u06a9\u06cc \u0627\u0632 \u0645\u0648\u0627\u0631\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0631\u0627\u06cc\u062c \u0628\u0631\u0627\u06cc \u062a\u0637\u0628\u06cc\u0642 \u0627\u0644\u06af\u0648 \u0628\u0627 \u0633\u0648\u0626\u06cc\u0686\u060c \u0647\u0646\u06af\u0627\u0645 \u06a9\u0627\u0631 \u0628\u0627 \u0627\u0646\u0648\u0627\u0639 \u0645\u062e\u062a\u0644\u0641 \u062f\u0627\u062f\u0647 \u062f\u0631 \u06cc\u06a9 \u0628\u0631\u0646\u0627\u0645\u0647 \u0627\u0633\u062a. \u0645\u062b\u0627\u0644 \u0632\u06cc\u0631 \u0627\u0632 \u06cc\u06a9 \u06a9\u0644\u0627\u0633 WeatherStation \u0631\u0627 \u062f\u0631 \u0646\u0638\u0631 \u0628\u06af\u06cc\u0631\u06cc\u062f \u06a9\u0647 \u062f\u0627\u0631\u0627\u06cc \u0627\u0646\u0648\u0627\u0639 \u0645\u062e\u062a\u0644\u0641\u06cc \u0627\u0632 \u0633\u0646\u0633\u0648\u0631\u0647\u0627 \u0627\u0633\u062a \u0648 \u062f\u0645\u0627\u06cc \u0641\u0639\u0644\u06cc \u0631\u0627 \u0628\u0631\u0645\u06cc \u06af\u0631\u062f\u0627\u0646\u062f:<\/p>\n<p>`\u06a9\u0644\u0627\u0633 \u0639\u0645\u0648\u0645\u06cc \u0627\u06cc\u0633\u062a\u06af\u0627\u0647 \u0647\u0648\u0627\u0634\u0646\u0627\u0633\u06cc {<\/p>\n<p>private Sensor sensor;<\/p>\n<p> public double getCurrentTemperature() {<br \/>\n    return switch (sensor) {<br \/>\n        case TemperatureSensor t -&gt; t.reading();<br \/>\n        case HumiditySensor h -&gt; h.reading() * 0.9; \/\/ apply a 10% moisture correction<br \/>\n        default -&gt; 0.0; \/\/ in case of an unhandled sensor type, return 0<br \/>\n    };<br \/>\n}<\/p>\n<p>}<br \/>\n`<br \/>\n\u062f\u0631 \u0627\u06cc\u0646\u062c\u0627\u060c \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u0645 \u0628\u0628\u06cc\u0646\u06cc\u0645 \u06a9\u0647 \u06cc\u06a9 \u0631\u0627\u0628\u0637 Sensor \u0628\u0631\u0627\u06cc \u0639\u0628\u0627\u0631\u062a \u0627\u0646\u062a\u062e\u0627\u0628\u06af\u0631 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc\u200c\u0634\u0648\u062f\u060c \u0648 \u0628\u0631\u0686\u0633\u0628\u200c\u0647\u0627\u06cc \u0645\u0648\u0631\u062f \u0627\u0632 \u0627\u0644\u06af\u0648\u0647\u0627\u06cc\u06cc \u0628\u0631 \u0627\u0633\u0627\u0633 \u067e\u06cc\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc\u200c\u0647\u0627\u06cc \u062e\u0627\u0635 \u0633\u0646\u0633\u0648\u0631 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc\u200c\u06a9\u0646\u0646\u062f: TemperatureSensor \u0648 HumiditySensor. \u0627\u06cc\u0646 \u0627\u062c\u0627\u0632\u0647 \u0645\u06cc \u062f\u0647\u062f \u062a\u0627 \u0631\u0648\u0634\u06cc \u0645\u062e\u062a\u0635\u0631 \u0648 \u0642\u0627\u0628\u0644 \u062e\u0648\u0627\u0646\u062f\u0646 \u0628\u0631\u0627\u06cc \u0645\u062f\u06cc\u0631\u06cc\u062a \u0627\u0646\u0648\u0627\u0639 \u0645\u062e\u062a\u0644\u0641 \u062f\u0627\u062f\u0647 \u0647\u0627 \u062f\u0631 \u062f\u0633\u062a\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686 \u0648\u062c\u0648\u062f \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f.<\/p>\n<p>\u06cc\u06a9\u06cc \u062f\u06cc\u06af\u0631 \u0627\u0632 \u0645\u0648\u0627\u0631\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0628\u0631\u0627\u06cc \u062a\u0637\u0628\u06cc\u0642 \u0627\u0644\u06af\u0648 \u0628\u0627 \u0633\u0648\u0626\u06cc\u0686\u060c \u0632\u0645\u0627\u0646\u06cc \u0627\u0633\u062a \u06a9\u0647 \u0628\u0627 enums \u0633\u0631\u0648\u06a9\u0627\u0631 \u062f\u0627\u0631\u06cc\u0645. \u0642\u0628\u0644 \u0627\u0632 \u0645\u0639\u0631\u0641\u06cc \u062a\u0637\u0628\u06cc\u0642 \u0627\u0644\u06af\u0648\u060c enums \u0641\u0642\u0637 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u0633\u062a \u0628\u0647\u200c\u0639\u0646\u0648\u0627\u0646 \u062b\u0627\u0628\u062a \u062f\u0631 \u0628\u0631\u0686\u0633\u0628\u200c\u0647\u0627\u06cc \u062d\u0631\u0648\u0641 \u0645\u0648\u0631\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0642\u0631\u0627\u0631 \u06af\u06cc\u0631\u062f \u0648 \u0645\u0642\u0627\u062f\u06cc\u0631\u06cc \u0631\u0627 \u06a9\u0647 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646 \u0628\u0627 \u0622\u0646\u0647\u0627 \u062f\u0631 \u06cc\u06a9 \u062f\u0633\u062a\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686 \u0622\u0632\u0645\u0627\u06cc\u0634 \u06a9\u0631\u062f\u060c \u0645\u062d\u062f\u0648\u062f \u06a9\u0631\u062f. \u0628\u0627 \u0648\u06cc\u0698\u06af\u06cc \u062c\u062f\u06cc\u062f\u060c enums \u0627\u06a9\u0646\u0648\u0646 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u062f \u062f\u0631 \u0628\u0631\u0686\u0633\u0628\u200c\u0647\u0627\u06cc \u062d\u0631\u0648\u0641 \u0645\u0646\u0627\u0633\u0628 \u0628\u0627\u0634\u062f \u06a9\u0647 \u0627\u0645\u06a9\u0627\u0646 \u062a\u0637\u0628\u06cc\u0642 \u062f\u0642\u06cc\u0642\u200c\u062a\u0631 \u0648 \u0627\u0646\u0639\u0637\u0627\u0641\u200c\u067e\u0630\u06cc\u0631\u062a\u0631 \u0631\u0627 \u0641\u0631\u0627\u0647\u0645 \u0645\u06cc\u200c\u06a9\u0646\u062f.<\/p>\n<p>public enum Direction {<br \/>\n    NORTH,<br \/>\n    EAST,<br \/>\n    SOUTH,<br \/>\n    WEST<br \/>\n}<\/p>\n<p>public void move(Direction direction) {<br \/>\n    switch (direction) {<br \/>\n        case NORTH,NORTH_WEST,NORTH_EAST -&gt; moveUp();<br \/>\n        case EAST,EAST_NORTH,EAST_SOUTH -&gt; moveRight();<br \/>\n        case SOUTH,SOUTH_EAST,SOUTH_WEST -&gt; moveDown();<br \/>\n        case WEST,WEST_NORTH,WEST_SOUTH -&gt; moveLeft();<br \/>\n    }<br \/>\n}<\/p>\n<p>\u062f\u0631 \u0627\u06cc\u0646\u062c\u0627\u060c \u0645\u062a\u062f move() \u0627\u0632 \u06cc\u06a9 \u062f\u0633\u062a\u0648\u0631 switch \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u06a9\u0646\u062f \u062a\u0627 \u0628\u0647 \u0631\u0627\u062d\u062a\u06cc \u062d\u0631\u06a9\u062a \u062f\u0631 \u062c\u0647\u0627\u062a \u0645\u062e\u062a\u0644\u0641 \u0631\u0627 \u0628\u0631 \u0627\u0633\u0627\u0633 \u0645\u0642\u062f\u0627\u0631 \u062c\u0647\u062a enum \u0645\u0634\u062e\u0635 \u0634\u062f\u0647 \u06a9\u0646\u062a\u0631\u0644 \u06a9\u0646\u062f. \u0628\u0627 \u062a\u0637\u0628\u06cc\u0642 \u0627\u0644\u06af\u0648\u060c \u0645\u0627 \u0647\u0645\u0686\u0646\u06cc\u0646 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u0645 \u062a\u0631\u06a9\u06cc\u0628\u200c\u0647\u0627\u06cc \u062c\u0647\u062a\u200c\u062f\u0627\u0631\u060c \u0645\u0627\u0646\u0646\u062f NORTH_WEST \u0648 EAST_SOUTH \u0631\u0627 \u0645\u0634\u062e\u0635 \u06a9\u0646\u06cc\u0645\u060c \u06a9\u0647 \u06a9\u062f \u0645\u0627 \u0631\u0627 \u0642\u0648\u06cc\u200c\u062a\u0631 \u0648 \u0627\u0646\u0639\u0637\u0627\u0641\u200c\u067e\u0630\u06cc\u0631\u062a\u0631 \u0645\u06cc\u200c\u06a9\u0646\u062f.<\/p>\n<p>\u062f\u0631 \u0646\u0647\u0627\u06cc\u062a\u060c \u0628\u06cc\u0627\u06cc\u06cc\u062f \u0628\u0647 \u0645\u062b\u0627\u0644\u06cc \u0646\u06af\u0627\u0647 \u06a9\u0646\u06cc\u0645 \u06a9\u0647 \u0686\u06af\u0648\u0646\u0647 \u062a\u0637\u0628\u06cc\u0642 \u0627\u0644\u06af\u0648 \u0645\u06cc \u062a\u0648\u0627\u0646\u062f \u0628\u0647 \u0645\u062f\u06cc\u0631\u06cc\u062a \u062e\u0637\u0627 \u062f\u0631 \u062f\u0633\u062a\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686 \u06a9\u0645\u06a9 \u06a9\u0646\u062f. \u062f\u0631 \u0633\u0648\u0626\u06cc\u0686 \u0633\u0646\u062a\u06cc\u060c \u0627\u06af\u0631 \u0639\u0628\u0627\u0631\u062a \u0627\u0646\u062a\u062e\u0627\u0628\u06af\u0631 \u0628\u0627 \u0647\u06cc\u0686 \u06cc\u06a9 \u0627\u0632 \u0628\u0631\u0686\u0633\u0628 \u0647\u0627\u06cc case \u0645\u0637\u0627\u0628\u0642\u062a \u0646\u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f\u060c \u0645\u06cc \u062a\u0648\u0627\u0646 \u0627\u0632 \u06cc\u06a9 case \u067e\u06cc\u0634 \u0641\u0631\u0636 \u0628\u0631\u0627\u06cc \u0631\u0633\u06cc\u062f\u06af\u06cc \u0628\u0647 \u062e\u0637\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0631\u062f. \u0628\u0627 \u0627\u06cc\u0646 \u062d\u0627\u0644\u060c \u0627\u06cc\u0646 \u0645\u0645\u06a9\u0646 \u0627\u0633\u062a \u062f\u0631 \u0647\u0646\u06af\u0627\u0645 \u0628\u0631\u062e\u0648\u0631\u062f \u0628\u0627 \u0628\u0631\u0686\u0633\u0628\u200c\u0647\u0627\u06cc \u0645\u0648\u0631\u062f \u0645\u062a\u0639\u062f\u062f \u062e\u0633\u062a\u0647\u200c\u06a9\u0646\u0646\u062f\u0647 \u0628\u0627\u0634\u062f \u0648 \u0645\u0646\u062c\u0631 \u0628\u0647 \u062a\u06a9\u0631\u0627\u0631 \u06a9\u062f \u0634\u0648\u062f. \u062f\u0631 \u062a\u0637\u0628\u06cc\u0642 \u0627\u0644\u06af\u0648\u060c \u062f\u0631 \u0635\u0648\u0631\u062a\u06cc \u06a9\u0647 \u0647\u06cc\u0686 \u06cc\u06a9 \u0627\u0632 \u0627\u0644\u06af\u0648\u0647\u0627\u06cc \u0628\u0631\u0686\u0633\u0628 \u062d\u0631\u0648\u0641 \u0628\u0627 \u0639\u0628\u0627\u0631\u062a \u0627\u0646\u062a\u062e\u0627\u0628\u06af\u0631 \u0645\u0637\u0627\u0628\u0642\u062a \u0646\u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f\u060c \u06cc\u06a9 \u0627\u0633\u062a\u062b\u0646\u0627 \u0627\u06cc\u062c\u0627\u062f \u0645\u06cc\u200c\u0634\u0648\u062f \u0648 \u0645\u062f\u06cc\u0631\u06cc\u062a \u062e\u0637\u0627 \u0631\u0627 \u06cc\u06a9\u0646\u0648\u0627\u062e\u062a\u200c\u062a\u0631 \u0648 \u06a9\u0645\u062a\u0631 \u0645\u0633\u062a\u0639\u062f \u062e\u0637\u0627 \u0645\u06cc\u200c\u06a9\u0646\u062f.<\/p>\n<p>public String getPlanetaryObject(PlanetaryBody body) {<br \/>\n    return switch (body) {<br \/>\n        case Planet p &amp;&amp; p.getMass() &gt; 1e29 -&gt; p.getName() + &#8221; is a gas giant&#8221;;<br \/>\n        case Planet p &amp;&amp; p.getMass() &gt; 1e23 -&gt; p.getName() + &#8221; is a rocky planet&#8221;;<br \/>\n        case Star s &amp;&amp; s.getLuminosity() &gt; 1e32 -&gt; s.getName() + &#8221; is a bright star&#8221;;<br \/>\n        case Star s &amp;&amp; s.getLuminosity() &lt; 1e28 -&gt; s.getName() + &#8221; is a dim star&#8221;;<br \/>\n        default -&gt; throw new MatchException(&#8220;Unable to determine type of planetary object: &#8221; + body.getName());<br \/>\n    };<br \/>\n}<\/p>\n<p>\u062f\u0631 \u0627\u06cc\u0646 \u0645\u062b\u0627\u0644\u060c \u0645\u062a\u062f getPlanetaryObject() \u06cc\u06a9 \u062c\u0633\u0645 PlanetaryBody \u0631\u0627 \u0645\u06cc \u06af\u06cc\u0631\u062f \u06a9\u0647 \u0645\u06cc \u062a\u0648\u0627\u0646\u062f \u0633\u06cc\u0627\u0631\u0647 \u06cc\u0627 \u0633\u062a\u0627\u0631\u0647 \u0628\u0627\u0634\u062f. \u0627\u0644\u06af\u0648\u0647\u0627\u06cc \u0645\u0648\u0631\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u062f\u0631 \u0628\u0631\u0686\u0633\u0628\u200c\u0647\u0627\u06cc \u0642\u0627\u0628\u060c \u0634\u0631\u0627\u06cc\u0637 \u0627\u0636\u0627\u0641\u06cc \u0645\u0627\u0646\u0646\u062f \u062c\u0631\u0645 \u0633\u06cc\u0627\u0631\u0647 \u06cc\u0627 \u062f\u0631\u062e\u0634\u0646\u062f\u06af\u06cc \u0633\u062a\u0627\u0631\u0647 \u0631\u0627 \u062f\u0631 \u0646\u0638\u0631 \u0645\u06cc\u200c\u06af\u06cc\u0631\u0646\u062f. \u0627\u06af\u0631 \u0647\u06cc\u0686 \u06cc\u06a9 \u0627\u0632 \u0627\u0644\u06af\u0648\u0647\u0627 \u0645\u0637\u0627\u0628\u0642\u062a \u0646\u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f\u060c MatchException \u067e\u0631\u062a\u0627\u0628 \u0645\u06cc \u0634\u0648\u062f\u060c \u06a9\u0647 \u0645\u062f\u06cc\u0631\u06cc\u062a \u062e\u0637\u0627 \u0631\u0627 \u0633\u0627\u0632\u06af\u0627\u0631\u062a\u0631 \u0645\u06cc \u06a9\u0646\u062f \u0648 \u0627\u0632 \u0647\u0631\u06af\u0648\u0646\u0647 \u062e\u0637\u0627\u06cc \u0627\u062d\u062a\u0645\u0627\u0644\u06cc \u062c\u0644\u0648\u06af\u06cc\u0631\u06cc \u0645\u06cc \u06a9\u0646\u062f. <\/p>\n<p>\u0646\u062a\u06cc\u062c\u0647 \u06af\u06cc\u0631\u06cc<br \/>\n\u062a\u0637\u0628\u06cc\u0642 \u0627\u0644\u06af\u0648 \u0628\u0631\u0627\u06cc \u0633\u0648\u0626\u06cc\u0686 \u06cc\u06a9\u06cc \u0627\u0632 \u0645\u0647\u0645 \u062a\u0631\u06cc\u0646 \u0648\u06cc\u0698\u06af\u06cc \u0647\u0627\u06cc\u06cc \u0627\u0633\u062a \u06a9\u0647 \u062f\u0631 \u0632\u0645\u0627\u0646 \u0647\u0627\u06cc \u0627\u062e\u06cc\u0631 \u062f\u0631 \u062c\u0627\u0648\u0627 \u0645\u0639\u0631\u0641\u06cc \u0634\u062f\u0647 \u0627\u0633\u062a. \u0627\u06cc\u0646 \u0627\u0645\u06a9\u0627\u0646 \u0631\u0627 \u0628\u0631\u0627\u06cc \u0633\u0627\u062e\u062a\u0627\u0631\u0647\u0627\u06cc \u06a9\u0646\u062a\u0631\u0644 \u062c\u0631\u06cc\u0627\u0646 \u0627\u0646\u0639\u0637\u0627\u0641 \u067e\u0630\u06cc\u0631\u062a\u0631 \u0648 \u0645\u062e\u062a\u0635\u0631\u062a\u0631 \u0641\u0631\u0627\u0647\u0645 \u0645\u06cc \u06a9\u0646\u062f.<\/p>\n<p>\u0645\u0647\u0627\u0631\u062a \u0647\u0627\u06cc \u062c\u0627\u0648\u0627 \u062e\u0648\u062f \u0631\u0627 \u0628\u0627 \u062f\u0631\u06cc\u0627\u0641\u062a \u06af\u0648\u0627\u0647\u06cc\u0646\u0627\u0645\u0647 \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633 \u062d\u0631\u0641\u0647 \u0627\u06cc Java SE 21 \u0627\u0631\u062a\u0642\u0627 \u062f\u0647\u06cc\u062f.<\/p>\n<p>\u06cc\u06a9\u06cc \u0627\u0632 \u0645\u0648\u0627\u0631\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0631\u0627\u06cc\u062c \u0628\u0631\u0627\u06cc \u062a\u0637\u0628\u06cc\u0642 \u0627\u0644\u06af\u0648 \u0628\u0627 \u0633\u0648\u0626\u06cc\u0686\u060c \u0647\u0646\u06af\u0627\u0645 \u06a9\u0627\u0631 \u0628\u0627 \u0627\u0646\u0648\u0627\u0639 \u0645\u062e\u062a\u0644\u0641 \u062f\u0627\u062f\u0647 \u062f\u0631 \u06cc\u06a9 \u0628\u0631\u0646\u0627\u0645\u0647 \u0627\u0633\u062a. \u0645\u062b\u0627\u0644 \u0632\u06cc\u0631 \u0627\u0632 \u06cc\u06a9 \u06a9\u0644\u0627\u0633 WeatherStation \u0631\u0627 \u062f\u0631 \u0646\u0638\u0631 \u0628\u06af\u06cc\u0631\u06cc\u062f \u06a9\u0647 \u062f\u0627\u0631\u0627\u06cc \u0627\u0646\u0648\u0627\u0639 \u0645\u062e\u062a\u0644\u0641\u06cc \u0627\u0632 \u0633\u0646\u0633\u0648\u0631\u0647\u0627 \u0627\u0633\u062a \u0648 \u062f\u0645\u0627\u06cc \u0641\u0639\u0644\u06cc \u0631\u0627 \u0628\u0631\u0645\u06cc \u06af\u0631\u062f\u0627\u0646\u062f:<\/p>\n<p>`\u06a9\u0644\u0627\u0633 \u0639\u0645\u0648\u0645\u06cc \u0627\u06cc\u0633\u062a\u06af\u0627\u0647 \u0647\u0648\u0627\u0634\u0646\u0627\u0633\u06cc {<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>private Sensor sensor;\n\n public double getCurrentTemperature() {\n    return switch (sensor) {\n        case TemperatureSensor t -&gt; t.reading();\n        case HumiditySensor h -&gt; h.reading() * 0.9; \/\/ apply a 10% moisture correction\n        default -&gt; 0.0; \/\/ in case of an unhandled sensor type, return 0\n    };\n}\n<\/code><\/pre>\n<\/div>\n<p>}<br \/>\n`<br \/>\n\u062f\u0631 \u0627\u06cc\u0646\u062c\u0627\u060c \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u0645 \u0628\u0628\u06cc\u0646\u06cc\u0645 \u06a9\u0647 \u06cc\u06a9 \u0631\u0627\u0628\u0637 Sensor \u0628\u0631\u0627\u06cc \u0639\u0628\u0627\u0631\u062a \u0627\u0646\u062a\u062e\u0627\u0628\u06af\u0631 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc\u200c\u0634\u0648\u062f\u060c \u0648 \u0628\u0631\u0686\u0633\u0628\u200c\u0647\u0627\u06cc \u0645\u0648\u0631\u062f \u0627\u0632 \u0627\u0644\u06af\u0648\u0647\u0627\u06cc\u06cc \u0628\u0631 \u0627\u0633\u0627\u0633 \u067e\u06cc\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc\u200c\u0647\u0627\u06cc \u062e\u0627\u0635 \u0633\u0646\u0633\u0648\u0631 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc\u200c\u06a9\u0646\u0646\u062f: TemperatureSensor \u0648 HumiditySensor. \u0627\u06cc\u0646 \u0627\u062c\u0627\u0632\u0647 \u0645\u06cc \u062f\u0647\u062f \u062a\u0627 \u0631\u0648\u0634\u06cc \u0645\u062e\u062a\u0635\u0631 \u0648 \u0642\u0627\u0628\u0644 \u062e\u0648\u0627\u0646\u062f\u0646 \u0628\u0631\u0627\u06cc \u0645\u062f\u06cc\u0631\u06cc\u062a \u0627\u0646\u0648\u0627\u0639 \u0645\u062e\u062a\u0644\u0641 \u062f\u0627\u062f\u0647 \u0647\u0627 \u062f\u0631 \u062f\u0633\u062a\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686 \u0648\u062c\u0648\u062f \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f.<\/p>\n<p>\u06cc\u06a9\u06cc \u062f\u06cc\u06af\u0631 \u0627\u0632 \u0645\u0648\u0627\u0631\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0628\u0631\u0627\u06cc \u062a\u0637\u0628\u06cc\u0642 \u0627\u0644\u06af\u0648 \u0628\u0627 \u0633\u0648\u0626\u06cc\u0686\u060c \u0632\u0645\u0627\u0646\u06cc \u0627\u0633\u062a \u06a9\u0647 \u0628\u0627 enums \u0633\u0631\u0648\u06a9\u0627\u0631 \u062f\u0627\u0631\u06cc\u0645. \u0642\u0628\u0644 \u0627\u0632 \u0645\u0639\u0631\u0641\u06cc \u062a\u0637\u0628\u06cc\u0642 \u0627\u0644\u06af\u0648\u060c enums \u0641\u0642\u0637 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u0633\u062a \u0628\u0647\u200c\u0639\u0646\u0648\u0627\u0646 \u062b\u0627\u0628\u062a \u062f\u0631 \u0628\u0631\u0686\u0633\u0628\u200c\u0647\u0627\u06cc \u062d\u0631\u0648\u0641 \u0645\u0648\u0631\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0642\u0631\u0627\u0631 \u06af\u06cc\u0631\u062f \u0648 \u0645\u0642\u0627\u062f\u06cc\u0631\u06cc \u0631\u0627 \u06a9\u0647 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646 \u0628\u0627 \u0622\u0646\u0647\u0627 \u062f\u0631 \u06cc\u06a9 \u062f\u0633\u062a\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686 \u0622\u0632\u0645\u0627\u06cc\u0634 \u06a9\u0631\u062f\u060c \u0645\u062d\u062f\u0648\u062f \u06a9\u0631\u062f. \u0628\u0627 \u0648\u06cc\u0698\u06af\u06cc \u062c\u062f\u06cc\u062f\u060c enums \u0627\u06a9\u0646\u0648\u0646 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u062f \u062f\u0631 \u0628\u0631\u0686\u0633\u0628\u200c\u0647\u0627\u06cc \u062d\u0631\u0648\u0641 \u0645\u0646\u0627\u0633\u0628 \u0628\u0627\u0634\u062f \u06a9\u0647 \u0627\u0645\u06a9\u0627\u0646 \u062a\u0637\u0628\u06cc\u0642 \u062f\u0642\u06cc\u0642\u200c\u062a\u0631 \u0648 \u0627\u0646\u0639\u0637\u0627\u0641\u200c\u067e\u0630\u06cc\u0631\u062a\u0631 \u0631\u0627 \u0641\u0631\u0627\u0647\u0645 \u0645\u06cc\u200c\u06a9\u0646\u062f.<\/p>\n<p><code>public enum Direction {<br \/>\n    NORTH,<br \/>\n    EAST,<br \/>\n    SOUTH,<br \/>\n    WEST<br \/>\n}<br \/>\n<\/code><br \/>\n<code>public void move(Direction direction) {<br \/>\n    switch (direction) {<br \/>\n        case NORTH,NORTH_WEST,NORTH_EAST -&gt; moveUp();<br \/>\n        case EAST,EAST_NORTH,EAST_SOUTH -&gt; moveRight();<br \/>\n        case SOUTH,SOUTH_EAST,SOUTH_WEST -&gt; moveDown();<br \/>\n        case WEST,WEST_NORTH,WEST_SOUTH -&gt; moveLeft();<br \/>\n    }<br \/>\n}<br \/>\n<\/code><\/p>\n<p>\u062f\u0631 \u0627\u06cc\u0646\u062c\u0627\u060c \u0645\u062a\u062f move() \u0627\u0632 \u06cc\u06a9 \u062f\u0633\u062a\u0648\u0631 switch \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u06a9\u0646\u062f \u062a\u0627 \u0628\u0647 \u0631\u0627\u062d\u062a\u06cc \u062d\u0631\u06a9\u062a \u062f\u0631 \u062c\u0647\u0627\u062a \u0645\u062e\u062a\u0644\u0641 \u0631\u0627 \u0628\u0631 \u0627\u0633\u0627\u0633 \u0645\u0642\u062f\u0627\u0631 \u062c\u0647\u062a enum \u0645\u0634\u062e\u0635 \u0634\u062f\u0647 \u06a9\u0646\u062a\u0631\u0644 \u06a9\u0646\u062f. \u0628\u0627 \u062a\u0637\u0628\u06cc\u0642 \u0627\u0644\u06af\u0648\u060c \u0645\u0627 \u0647\u0645\u0686\u0646\u06cc\u0646 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u0645 \u062a\u0631\u06a9\u06cc\u0628\u200c\u0647\u0627\u06cc \u062c\u0647\u062a\u200c\u062f\u0627\u0631\u060c \u0645\u0627\u0646\u0646\u062f NORTH_WEST \u0648 EAST_SOUTH \u0631\u0627 \u0645\u0634\u062e\u0635 \u06a9\u0646\u06cc\u0645\u060c \u06a9\u0647 \u06a9\u062f \u0645\u0627 \u0631\u0627 \u0642\u0648\u06cc\u200c\u062a\u0631 \u0648 \u0627\u0646\u0639\u0637\u0627\u0641\u200c\u067e\u0630\u06cc\u0631\u062a\u0631 \u0645\u06cc\u200c\u06a9\u0646\u062f.<\/p>\n<p>\u062f\u0631 \u0646\u0647\u0627\u06cc\u062a\u060c \u0628\u06cc\u0627\u06cc\u06cc\u062f \u0628\u0647 \u0645\u062b\u0627\u0644\u06cc \u0646\u06af\u0627\u0647 \u06a9\u0646\u06cc\u0645 \u06a9\u0647 \u0686\u06af\u0648\u0646\u0647 \u062a\u0637\u0628\u06cc\u0642 \u0627\u0644\u06af\u0648 \u0645\u06cc \u062a\u0648\u0627\u0646\u062f \u0628\u0647 \u0645\u062f\u06cc\u0631\u06cc\u062a \u062e\u0637\u0627 \u062f\u0631 \u062f\u0633\u062a\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686 \u06a9\u0645\u06a9 \u06a9\u0646\u062f. \u062f\u0631 \u0633\u0648\u0626\u06cc\u0686 \u0633\u0646\u062a\u06cc\u060c \u0627\u06af\u0631 \u0639\u0628\u0627\u0631\u062a \u0627\u0646\u062a\u062e\u0627\u0628\u06af\u0631 \u0628\u0627 \u0647\u06cc\u0686 \u06cc\u06a9 \u0627\u0632 \u0628\u0631\u0686\u0633\u0628 \u0647\u0627\u06cc case \u0645\u0637\u0627\u0628\u0642\u062a \u0646\u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f\u060c \u0645\u06cc \u062a\u0648\u0627\u0646 \u0627\u0632 \u06cc\u06a9 case \u067e\u06cc\u0634 \u0641\u0631\u0636 \u0628\u0631\u0627\u06cc \u0631\u0633\u06cc\u062f\u06af\u06cc \u0628\u0647 \u062e\u0637\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0631\u062f. \u0628\u0627 \u0627\u06cc\u0646 \u062d\u0627\u0644\u060c \u0627\u06cc\u0646 \u0645\u0645\u06a9\u0646 \u0627\u0633\u062a \u062f\u0631 \u0647\u0646\u06af\u0627\u0645 \u0628\u0631\u062e\u0648\u0631\u062f \u0628\u0627 \u0628\u0631\u0686\u0633\u0628\u200c\u0647\u0627\u06cc \u0645\u0648\u0631\u062f \u0645\u062a\u0639\u062f\u062f \u062e\u0633\u062a\u0647\u200c\u06a9\u0646\u0646\u062f\u0647 \u0628\u0627\u0634\u062f \u0648 \u0645\u0646\u062c\u0631 \u0628\u0647 \u062a\u06a9\u0631\u0627\u0631 \u06a9\u062f \u0634\u0648\u062f. \u062f\u0631 \u062a\u0637\u0628\u06cc\u0642 \u0627\u0644\u06af\u0648\u060c \u062f\u0631 \u0635\u0648\u0631\u062a\u06cc \u06a9\u0647 \u0647\u06cc\u0686 \u06cc\u06a9 \u0627\u0632 \u0627\u0644\u06af\u0648\u0647\u0627\u06cc \u0628\u0631\u0686\u0633\u0628 \u062d\u0631\u0648\u0641 \u0628\u0627 \u0639\u0628\u0627\u0631\u062a \u0627\u0646\u062a\u062e\u0627\u0628\u06af\u0631 \u0645\u0637\u0627\u0628\u0642\u062a \u0646\u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f\u060c \u06cc\u06a9 \u0627\u0633\u062a\u062b\u0646\u0627 \u0627\u06cc\u062c\u0627\u062f \u0645\u06cc\u200c\u0634\u0648\u062f \u0648 \u0645\u062f\u06cc\u0631\u06cc\u062a \u062e\u0637\u0627 \u0631\u0627 \u06cc\u06a9\u0646\u0648\u0627\u062e\u062a\u200c\u062a\u0631 \u0648 \u06a9\u0645\u062a\u0631 \u0645\u0633\u062a\u0639\u062f \u062e\u0637\u0627 \u0645\u06cc\u200c\u06a9\u0646\u062f.<\/p>\n<p><code>public String getPlanetaryObject(PlanetaryBody body) {<br \/>\n    return switch (body) {<br \/>\n        case Planet p &amp;&amp; p.getMass() &gt; 1e29 -&gt; p.getName() + \" is a gas giant\";<br \/>\n        case Planet p &amp;&amp; p.getMass() &gt; 1e23 -&gt; p.getName() + \" is a rocky planet\";<br \/>\n        case Star s &amp;&amp; s.getLuminosity() &gt; 1e32 -&gt; s.getName() + \" is a bright star\";<br \/>\n        case Star s &amp;&amp; s.getLuminosity() &lt; 1e28 -&gt; s.getName() + \" is a dim star\";<br \/>\n        default -&gt; throw new MatchException(\"Unable to determine type of planetary object: \" + body.getName());<br \/>\n    };<br \/>\n}<\/code><\/p>\n<p>\u062f\u0631 \u0627\u06cc\u0646 \u0645\u062b\u0627\u0644\u060c \u0645\u062a\u062f getPlanetaryObject() \u06cc\u06a9 \u062c\u0633\u0645 PlanetaryBody \u0631\u0627 \u0645\u06cc \u06af\u06cc\u0631\u062f \u06a9\u0647 \u0645\u06cc \u062a\u0648\u0627\u0646\u062f \u0633\u06cc\u0627\u0631\u0647 \u06cc\u0627 \u0633\u062a\u0627\u0631\u0647 \u0628\u0627\u0634\u062f. \u0627\u0644\u06af\u0648\u0647\u0627\u06cc \u0645\u0648\u0631\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u062f\u0631 \u0628\u0631\u0686\u0633\u0628\u200c\u0647\u0627\u06cc \u0642\u0627\u0628\u060c \u0634\u0631\u0627\u06cc\u0637 \u0627\u0636\u0627\u0641\u06cc \u0645\u0627\u0646\u0646\u062f \u062c\u0631\u0645 \u0633\u06cc\u0627\u0631\u0647 \u06cc\u0627 \u062f\u0631\u062e\u0634\u0646\u062f\u06af\u06cc \u0633\u062a\u0627\u0631\u0647 \u0631\u0627 \u062f\u0631 \u0646\u0638\u0631 \u0645\u06cc\u200c\u06af\u06cc\u0631\u0646\u062f. \u0627\u06af\u0631 \u0647\u06cc\u0686 \u06cc\u06a9 \u0627\u0632 \u0627\u0644\u06af\u0648\u0647\u0627 \u0645\u0637\u0627\u0628\u0642\u062a \u0646\u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f\u060c MatchException \u067e\u0631\u062a\u0627\u0628 \u0645\u06cc \u0634\u0648\u062f\u060c \u06a9\u0647 \u0645\u062f\u06cc\u0631\u06cc\u062a \u062e\u0637\u0627 \u0631\u0627 \u0633\u0627\u0632\u06af\u0627\u0631\u062a\u0631 \u0645\u06cc \u06a9\u0646\u062f \u0648 \u0627\u0632 \u0647\u0631\u06af\u0648\u0646\u0647 \u062e\u0637\u0627\u06cc \u0627\u062d\u062a\u0645\u0627\u0644\u06cc \u062c\u0644\u0648\u06af\u06cc\u0631\u06cc \u0645\u06cc \u06a9\u0646\u062f. <\/p>\n<p>\u0646\u062a\u06cc\u062c\u0647 \u06af\u06cc\u0631\u06cc<br \/>\n\u062a\u0637\u0628\u06cc\u0642 \u0627\u0644\u06af\u0648 \u0628\u0631\u0627\u06cc \u0633\u0648\u0626\u06cc\u0686 \u06cc\u06a9\u06cc \u0627\u0632 \u0645\u0647\u0645 \u062a\u0631\u06cc\u0646 \u0648\u06cc\u0698\u06af\u06cc \u0647\u0627\u06cc\u06cc \u0627\u0633\u062a \u06a9\u0647 \u062f\u0631 \u0632\u0645\u0627\u0646 \u0647\u0627\u06cc \u0627\u062e\u06cc\u0631 \u062f\u0631 \u062c\u0627\u0648\u0627 \u0645\u0639\u0631\u0641\u06cc \u0634\u062f\u0647 \u0627\u0633\u062a. \u0627\u06cc\u0646 \u0627\u0645\u06a9\u0627\u0646 \u0631\u0627 \u0628\u0631\u0627\u06cc \u0633\u0627\u062e\u062a\u0627\u0631\u0647\u0627\u06cc \u06a9\u0646\u062a\u0631\u0644 \u062c\u0631\u06cc\u0627\u0646 \u0627\u0646\u0639\u0637\u0627\u0641 \u067e\u0630\u06cc\u0631\u062a\u0631 \u0648 \u0645\u062e\u062a\u0635\u0631\u062a\u0631 \u0641\u0631\u0627\u0647\u0645 \u0645\u06cc \u06a9\u0646\u062f.<\/p>\n<p>\u0645\u0647\u0627\u0631\u062a \u0647\u0627\u06cc \u062c\u0627\u0648\u0627 \u062e\u0648\u062f \u0631\u0627 \u0628\u0627 \u062f\u0631\u06cc\u0627\u0641\u062a \u06af\u0648\u0627\u0647\u06cc\u0646\u0627\u0645\u0647 \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633 \u062d\u0631\u0641\u0647 \u0627\u06cc Java SE 21 \u0627\u0631\u062a\u0642\u0627 \u062f\u0647\u06cc\u062f.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summarize this content to 400 words in Persian Lang \u06cc\u06a9\u06cc \u0627\u0632 \u0645\u0648\u0627\u0631\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0631\u0627\u06cc\u062c \u0628\u0631\u0627\u06cc \u062a\u0637\u0628\u06cc\u0642 \u0627\u0644\u06af\u0648 \u0628\u0627 \u0633\u0648\u0626\u06cc\u0686\u060c \u0647\u0646\u06af\u0627\u0645 \u06a9\u0627\u0631 \u0628\u0627 \u0627\u0646\u0648\u0627\u0639 \u0645\u062e\u062a\u0644\u0641 \u062f\u0627\u062f\u0647 \u062f\u0631 \u06cc\u06a9 \u0628\u0631\u0646\u0627\u0645\u0647 \u0627\u0633\u062a. \u0645\u062b\u0627\u0644 \u0632\u06cc\u0631 \u0627\u0632 \u06cc\u06a9 \u06a9\u0644\u0627\u0633 WeatherStation \u0631\u0627 \u062f\u0631 \u0646\u0638\u0631 \u0628\u06af\u06cc\u0631\u06cc\u062f \u06a9\u0647 \u062f\u0627\u0631\u0627\u06cc \u0627\u0646\u0648\u0627\u0639 \u0645\u062e\u062a\u0644\u0641\u06cc \u0627\u0632 \u0633\u0646\u0633\u0648\u0631\u0647\u0627 \u0627\u0633\u062a \u0648 \u062f\u0645\u0627\u06cc \u0641\u0639\u0644\u06cc \u0631\u0627 \u0628\u0631\u0645\u06cc \u06af\u0631\u062f\u0627\u0646\u062f: `\u06a9\u0644\u0627\u0633 \u0639\u0645\u0648\u0645\u06cc \u0627\u06cc\u0633\u062a\u06af\u0627\u0647 &hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[339],"tags":[],"class_list":["post-73441","post","type-post","status-publish","format-standard","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/73441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/comments?post=73441"}],"version-history":[{"count":0,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/73441\/revisions"}],"wp:attachment":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media?parent=73441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/categories?post=73441"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/tags?post=73441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}