static ãªã¡ã³ãã¼ã»ã¯ã©ã¹*1ã¯ã以ä¸ã®ããã« "private" ã¨ãã¦å®£è¨ã§ãã¾ãã
ãã®æã"java Main$Internal" ã¨æã£ã¦ãã® private ã¯ã©ã¹å
ã® main ã¡ã½ãããèµ·åã§ããã®ã§ããããã
class Main{ private static class Internal{ public static void main(String[] args){ System.out.println("Hello world!"); } } }
çãï¼ã§ãã
Java ã® main ã¡ã½ããã¯ã以ä¸ã®ãã¹ã¦ã®æ¡ä»¶ãæºããã¦ããå¿
è¦ãããã¾ãã*2
- public ã㤠static ã¡ã½ããã§ãããã¨
- æ»ãå¤ã®å®£è¨ã¯ void ã§ãããã¨
- ã¡ã½ããå㯠main ã§ãããã¨
- å¼æ°ã¯1ã¤ã§ãããã¨
- å¼æ°ã§ String ã®é åãåãåããã¨
ã¡ã½ããã«é¢ãã¦ã¯å¶ç´ãããã¾ãããã¯ã©ã¹ã«é¢ãã¦ã¯ãã¼ãã§ããã° OK ã¨ã®ãã¨ã
ãªã®ã§ãprivate ãªã¯ã©ã¹ã§ãåé¡ãªãèµ·åã§ããããã§ãã
ãããããjavap ãã¦ã¿ãéããã³ã³ãã¤ã«ãã段é㧠private ã¯ã©ã¹ã§ããã¨ããæ å ±ã¯æ¶ããã¦ãã®ã§ãå¤æãããããªãããã§ãâ¦ã
*1:ãstatic å é¨ã¯ã©ã¹ãã¨æ¸ããã¦ãããã¨ãããã¾ãããããã¯ééããè¨èªä»æ§ã® 8.1.3 ã§ãstatic ãªãã°å é¨ã¯ã©ã¹ã§ã¯ãªããã¨æè¨ããã¦ãã¾ãã
*2:Java ä»®æ³ãã·ã³ä»æ§ã«ã¯ã5.2 ä»®æ³ãã·ã³ã®éå§ ã§ããã® *public ã¯ã©ã¹* ã® ã¡ã½ãã void main(String[]) ãèµ·åãããã¨ãã¾ãããããã¯èª¤è¨³ãåæã®ééããã¨ã