JAVA基礎之util包

來源:互聯網
上載者:User
今天的作業^_^很簡單,但感覺JAVA的確提供了N多可以用的類,這點比C++好一點,但對於OOP語言機制的思考還是有一點沒由明白,C++因為是為了小型介面所設計的OOP語言,所以COM/COM+之類的封裝符合C++哲學,但如果一旦需要用C++封裝比較大型的類庫,ex:MFC~這對於效能來講簡直有點惡夢,當然MFC是採用了奇怪的marco和其他一些技術比如訊息映射躲避了C++的先天性不足,但JAVA有是通過什麼方式搞定這點的呢?有興趣的朋友一定和我交流一下,citypw@gmail.com
/*
 *請計算出距目前時間100天后的日期時間,並用"xxxx年xx月xx日"的格式輸出.
 *Shawn
 *CityPW@copyleft
 */
import java.util.Calendar;    //需要用到的類
class mydata {
    public static void main(String[] args)
    {
        Calendar cal1=Calendar.getInstance();
        cal1.add(Calendar.DAY_OF_MONTH,100);
        System.out.println(cal1.get(cal1.YEAR)+"年"+cal1.get(cal1.MONTH)+"月"+cal1.get(cal1.DAY_OF_MONTH)+"日");
    }
}

/*
 *請計算出距目前時間100天后的日期時間,並用"xxxx年xx月xx日"的格式輸出.
 *Shawn
 *CityPW@copyleft
 */
import java.util.HashMap;
class hashtest {
    public static void main(String[] args)
    {
        HashMap hashtest1=new HashMap();
        hashtest1.put("張三", 90);
        hashtest1.put("李四", 88);
       
        System.out.println("張三的成績:"+hashtest1.get("張三").toString());
        System.out.println("李四的成績:"+hashtest1.get("李四").toString());
       
        hashtest1.put("張三", 99);
       
        System.out.println("改動後張三的成績/n張三的成績:"+hashtest1.get("張三").toString());
    }

}
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.