Java ã使ãã«ããã®ã¯éçã ããã§ã¯ãªã
Java ã使ãã«ããè¨èªã§ããã¨ããã®ã¯ãä¸çä¸ã® LL ãã¡ã³ãçæã£ã¦ãããã¨ã ããããæ¹ãã¦ãããã¨ã§ããªããã©ã使ãã«ããã®ã¯éçè¨èªã ããã¨ããã®ã¯ééã£ã¦ãããJava ã使ãã«ããã®ã¯åã« Java ã®è¨è¨è ã®ã»ã³ã¹ãæªãã£ãã ãã§ãããéçè¨èªã®ããã§ã¯ãªãã
ãã¨ãã°ãããªã³ã¼ãã
public Map<String, List<String>> example() { List<String> list = new ArrayList<String>(); list.add("foo"); list.add("bar"); list.add("baz"); Map<String, List<String>> map = new HashMap<String, List<String>>(); map.put("names", list); return map; }
ã¾ããªãã¨ããã¾ãããMap ã List ã表ããªãã©ã«ããªãããã§ãè¨è¿°ãåé·ã«ãªã£ã¦ããããªããã©ãã List 㨠Map ã® 99 ãã¼ã»ã³ã㯠ArrayList 㨠HashMap ãªãã ããããããããããªãã©ã«ãç¨æãã¦ãããã¨æããåæå®ã®ããã§ãªãã©ã«ãé£ããã®ã§ããã°ããnew ArrayList
ï¼è¿½è¨(2008-03-07)ï¼ããªãã©ã«ãã¨ããè¨èã«éå°ã«åå¿ãã¦ãã人ãããããããã§ã®è¶£æ¨ã¯ãæ¬è³ªçã§ã¯ãªãè¨è¿°ãæ¸ãã㦠Java ã使ãããããããã¨ãããã¨ãªã®ã§ãã©ã¤ãã©ãªã§æ¸ãã®ã§ããã°ããã§çµæ§ (ã³ã¡ã³ããåç §ã®ãã¨)ãã¾ãããªãã©ã«ãç¨æãã¦ãããã¨æããããªãã©ã«ãé£ããã®ã§ããã°ãã¨æ¸ããããã«ã絶対ã«ãªãã©ã«ãå°å ¥ãã¹ãã ã¨ãã主張ã§ã¯ãªããããã¾ã§ãJava ã使ããããããããã®æ¹æ³ã®ã²ã¨ã¤ã¨ãã¦ææ¡ããã¾ã§ã§ãããä»ã®æ¹æ³ãå¦å®ãã¦ã¯ããªãã趣æ¨ãåéãããªãã§ããã ããããï¼
ã¾ã
public Map<String, List<String>> example() { var list = new ArrayList<String>(); list.add("foo").add("bar").add("baz"); var map = new HashMap<String, List<String>>(); map.put("names", list); return map; }
ãvarãã¨ããäºç´èªãå¢ããã¦ããããäºææ§ãåé¡ã«ãªããã©ãassert ã¨åãã§ã³ã³ãã¤ã«ãªãã·ã§ã³ã§ on/off ããã°ããã ããã
ãã¨ãã¢ã¯ã»ããµãããã¡ãã¡ getter 㨠setter ãå®ç¾©ããªãããããªãã®ããã«ãã«ããããããIDE ã§èªåçæããã°åé¡ãªããã¨ãã人ããããã©ããããªã®ãå¿ è¦ãªæç¹ã§ééã£ã¦ãã¨ã¯æããªãã®ã ããããã ããããæ¬è³ªçã§ãªãã³ã¼ããä½åè¡ãããæç¹ã§ãã½ã¼ã¹ã³ã¼ãã® readability ãä¸ãã£ã¦ãã¾ãããããªãã®ãã³ã¼ãè¡æ°ãæ°´å¢ãããããã®ä»æ§ã ã
ä¸ã® Java å±ã¯ãã®ã³ã¼ããè¦ã¦ããä½ãçåã«æããªãããã ãããããã
private int id; private String name; private Date updated; public int getId() { return this.id; } public void setId(int id) { this.id = id; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public Date getUpdated() { return this.date; } public void setUpdate(Date date) { this.date = date; }
ããã次ã®ããã«ç°¡åã«ãªã£ããããªã«ãåé¡ã§ãããã®ã ãããããã£ã¡ã®ã»ããæ¸ãã®ãç°¡åã ãããªã«ããæ¬è³ªçã§ãªãã³ã¼ãããªããªãããããã¸ãèªã¿ãããã
@accessor private int id; @accessor private String name; @accessor private Date updated;
ãããã£ã Java ã®ä½¿ãã«ããã¯ãéçè¨èªã§ãããã¨ã¨ã¯é¢ä¿ããªããJava ã®è¨èªè¨è¨è
ã¯ãä»æ§ãã³ã³ãã¯ãã«ãããã¨ã«ã¯æ³¨æãæã£ã¦ãããã© (ããã 1.5 ã§è¦ã£ãã)ã使ããããã«ã¤ãã¦ã¯ãã¾ãé¢å¿ããªãã£ãããã ãã¨ããããJava ã«éãã Struts ã¨ã EJB ã¨ãè¦ãéããSUN ã IBM ã«ã¯ä½¿ããããã«é¢ããã»ã³ã¹ããªãã使ãããã product ã¯ã»ã¨ãã©ãå人ã§ä½ã£ã OSS ã ã