锘??xml version="1.0" encoding="utf-8" standalone="yes"?>粉嫩av在线播放,欧美日韩一区在线观看,欧美午夜精品久久久久久人妖 http://www.aygfsteel.com/justfly/category/3314.html闄や簡浠栫溂鍓嶇殑灞忓箷錛岃繖涓漢浠涔堜篃娌$湅瑙併?lt;br/>琚懆鍥寸殑鐢佃剳綈囨嫢鐫錛屼粬鍙煡閬撲粬鎵鍒涢犵殑鐜板疄錛屼絾鍙堟剰璇嗗埌閭f槸铏氬夠銆?lt;br/>浠栧凡緇忚秴瓚婁簡鎶鏈備篃瓚呰秺浜嗘満鍣ㄣ?/description>zh-cnFri, 02 Mar 2007 02:14:20 GMTFri, 02 Mar 2007 02:14:20 GMT60Java 5.0涓殑鑼冨瀷(Generics)http://www.aygfsteel.com/justfly/archive/2005/09/13/12946.htmlJustfly ShiJustfly ShiTue, 13 Sep 2005 15:50:00 GMThttp://www.aygfsteel.com/justfly/archive/2005/09/13/12946.htmlhttp://www.aygfsteel.com/justfly/comments/12946.htmlhttp://www.aygfsteel.com/justfly/archive/2005/09/13/12946.html#Feedback2http://www.aygfsteel.com/justfly/comments/commentRss/12946.htmlhttp://www.aygfsteel.com/justfly/services/trackbacks/12946.html榪欓噷涓昏鏈夎繖涔堝嚑鐐硅娉ㄦ剰錛?br />0銆佽寖鍨嬬被涔嬮棿鐨勮漿鍨?br />1銆佽寖鍨嬬被鐨勭戶鎵?br />2銆佽寖鍨嬫柟娉曠殑override
3銆佸叧閿瓧 super 鍜宔xends鐨勪嬌鐢ㄣ?br />
package cn.justfly.study.tiger.generics;

import java.util.Collection;

/**
 * Sample of defining generics type
 * 
 * @author Justfly Shi 
 * created at 2005-8-25 22:03:09
 
*/

public class Defination<G_T, G_B> {
  
private G_T _t = null;

  
private G_B _b = null;

  
public G_B getB() {
    
return _b;
  }


  
public void setB(G_B b) {
    _b 
= b;
  }

  
  
//Generics Method
  <G_A> G_A abc(G_A a,Defination<G_T, ? extends G_B> f)//keyword extends
  {
    
return a;
  }


  
//class Generics Method
  static <G_F,G_F2> void test(G_F[] a, Collection super G_F> b)// keyword super 
  {
    
for (G_F o : a) {
      b.add(o);
    }

  }


  
public G_T getT() {
    
return _t;
  }


  
public void setT(G_T t) {
    _t 
= t;
  }


  
public Defination(G_T t, G_B b) {
    super();
    _b 
= b;
    _t 
= t;
  }


  
/**
   * @param args
   
*/

  
public static void main(String[] args) {
    Defination
<A, A> d = new Defination<A, A>(new AImp2(), new AImp1());
    printDefination(d);

    
// about extends
    Defination<A, A> right = new SubDefination<A, A>(new AImp2(), new AImp1());
    printDefination(right);
    
// Type mismatch: cannot convert from SubDefination// Defination// Defination// AImp1());

    
// Type mismatch: cannot convert from Defination// Defination// Defination// AImp1());
  }


  
private static void printDefination(Defination<A, A> defination) {
    A t 
= defination.getT();
    A b 
= defination.getB();
    System.
out.println(t.getValue());
    System.
out.println(b.getValue());
  }

}


class SubDefination<G_T, G_J> extends Defination<G_T, G_J> {

  
public SubDefination(G_T t, G_J b) {
    super(t, b);
  }

  
  @Override
  
<G_A> G_A abc(G_A a, Defination<G_T, ? extends G_J> f) {
    
return super.abc(a, f);
  }

  
}


class A {
  String getValue() 
{
    
return "class A";
  }

}


class AImp1 extends A {
  
public String getValue() {
    
return "class AImp1";
  }

}


class AImp2 extends A {
  
public String getValue() {
    
return "class AImp2";
  }

}

鏈鍚庡啀鎺ㄨ崘涓綃囦腑鏂囩殑鑼冨瀷瀛︿範璧勬枡
鍦‥clipse 3.1涓綋楠孞2SE 5.0鐨勬柊鐗規?: 絎笁閮ㄥ垎 錛氳寖鍨?/a>

]]>
Java 5.0涓殑鍒椾婦綾誨瀷http://www.aygfsteel.com/justfly/archive/2005/09/13/12804.htmlJustfly ShiJustfly ShiMon, 12 Sep 2005 16:02:00 GMThttp://www.aygfsteel.com/justfly/archive/2005/09/13/12804.htmlhttp://www.aygfsteel.com/justfly/comments/12804.htmlhttp://www.aygfsteel.com/justfly/archive/2005/09/13/12804.html#Feedback0http://www.aygfsteel.com/justfly/comments/commentRss/12804.htmlhttp://www.aygfsteel.com/justfly/services/trackbacks/12804.htmlEnum涔熸槸java涓垜姣旇緝鍠滄鐨勪竴涓敼榪涳紝铏界劧浣跨敤鍒扮殑鍦版柟騫朵笉澶氥?br />姣忎竴涓猠num綾誨瀷閮介粯璁ょ殑緇ф壙浜唈ava.lang.Enum铏氭嫙綾匯?br />姣忎竴涓垪涓懼疄渚嬮兘鏄敼enum綾誨瀷鐨勪竴涓疄渚嬨?/p>
package cn.justfly.study.tiger.enums;

/**
 * Sample code of enum
 * 
 * @author Justfly Shi created at 2005-9-12 23:59:59
 
*/
public enum Gentle {
  WOMAN(
":)"), MAN(":|");
  Gentle(String hello) {
    _hello 
= hello;
  }

  String _hello;

  String sayHello() {
    
return _hello;
  }

  
public static void main(String[] args) {
    System.
out.println(Gentle.MAN.getDeclaringClass());

    Gentle[] allGentles 
= Gentle.values();
    System.
out.println("There are " + allGentles.length + " Gentles");
    
for (Gentle g : allGentles) {
      System.
out.println("index: " + g.ordinal() + " name: " + g.name()
          
+ " HelloSmile: " + g.sayHello());
    }
  }
}


]]>
Java 5.0涓敼榪涚殑for寰幆http://www.aygfsteel.com/justfly/archive/2005/09/12/12802.htmlJustfly ShiJustfly ShiMon, 12 Sep 2005 15:44:00 GMThttp://www.aygfsteel.com/justfly/archive/2005/09/12/12802.htmlhttp://www.aygfsteel.com/justfly/comments/12802.htmlhttp://www.aygfsteel.com/justfly/archive/2005/09/12/12802.html#Feedback0http://www.aygfsteel.com/justfly/comments/commentRss/12802.htmlhttp://www.aygfsteel.com/justfly/services/trackbacks/12802.html
package cn.justfly.study.tiger.enhancedfor;

import java.util.ArrayList;
import java.util.Collection;


/**
 * The demo of enhanced for statement
 * it can only used for array and classes implements java.util.Iterable interface
 * @author Justfly Shi
 * created at 2005-8-28 21:42:12
 
*/
public class EnhancedFor {

  
/**
   * @param args
   
*/
  
public static void main(String[] args) {
    
//for array
    int[] intArray={1,2,3,4};
    System.
out.println("printing ints:");
    
for(int i:intArray){
      System.
out.println(i);   
    }
    
    
//for Collection
   Collection<String> list=new ArrayList<String>();
    
for(int i=0;i<4;i++){
      list.add(
"String"+i);
    }
    System.
out.println("print Strings in an Collection:");
    
for(String i:list){
      System.
out.println(i);
    }
    
    
//self-define Iterable
    MyIterable<String> myIte=new MyIterable<String>(list);
    System.
out.println("print Stings in an Iterable");
    
for(String i:myIte){
      System.
out.println(i);
    }
    
  }

}

package cn.justfly.study.tiger.enhancedfor;

import java.util.Collection;
import java.util.Iterator;

/**
 * an self-defined Iterable ,that can be used in enhanced-for statement 
 * @author Justfly Shi
 * created at 2005-8-28 22:09:05
 * @param 
 
*/
public class MyIterable<G_E> implements Iterable<G_E> {
  
private Collection<G_E> _list;

  
public Iterator<G_E> iterator() {
    
return new MyIterator<G_E>(_list.iterator());
  }

  
public MyIterable(Collection<G_E> list) {
    _list 
= list;
  }

  
class MyIterator<G_I> implements Iterator<G_I> {
    
private Iterator<G_I> _ite;

    MyIterator(Iterator
<G_I> ite) {
      _ite 
= ite;
    }

    
public boolean hasNext() {
      
return _ite.hasNext();
    }

    
public G_I next() {
      
return _ite.next();
    }

    
public void remove() {
      _ite.remove();

    }
  }
}

杈撳嚭緇撴灉
printing ints:
1
2
3
4
print Strings in an Collection:
String0
String1
String2
String3
print Stings in an Iterable
String0
String1
String2
String3


]]>
Java 5.0涓殑鍙彉鍙傛暟鍒?/title><link>http://www.aygfsteel.com/justfly/archive/2005/09/12/12797.html</link><dc:creator>Justfly Shi</dc:creator><author>Justfly Shi</author><pubDate>Mon, 12 Sep 2005 15:17:00 GMT</pubDate><guid>http://www.aygfsteel.com/justfly/archive/2005/09/12/12797.html</guid><wfw:comment>http://www.aygfsteel.com/justfly/comments/12797.html</wfw:comment><comments>http://www.aygfsteel.com/justfly/archive/2005/09/12/12797.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/justfly/comments/commentRss/12797.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/justfly/services/trackbacks/12797.html</trackback:ping><description><![CDATA[濡備笅鍒椾唬鐮佹墍紺?br /><br />1銆佷紶鍏ョ殑鍙彉鍙傛暟灝嗗仛涓轟竴涓暟緇勫鐞?br />2銆佷竴涓嚱鏁頒腑鍙兘鏈変竴涓彲鍙樺弬鏁板垪錛屽茍涓斿彧鑳藉湪鍑芥暟鍙傛暟瀹氫箟鐨勬渶鍚庛?br /> <div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; background: rgb(230, 230, 230) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; width: 98%;"> <div><span style="color: rgb(0, 0, 0);">package cn.justfly.study.tiger;<br /><br /></span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">*<br /> * Sample of using varargs<br /> * @author Justfly Shi<br /> * created at 2005-8-31 0:38:19<br /> </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> Varargs {<br />  </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> printObjectArgs(Object<img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /> objects ){<br />    </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(Object o:objects)</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> objects is an Object Array</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">    {<br />      System.</span><span style="color: rgb(0, 0, 255);">out</span><span style="color: rgb(0, 0, 0);">.println(o);<br />    }<br />    System.</span><span style="color: rgb(0, 0, 255);">out</span><span style="color: rgb(0, 0, 0);">.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">var count:</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> objects.length);<br />  }<br />  </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> printFloats(</span><span style="color: rgb(0, 0, 255);">float</span><span style="color: rgb(0, 0, 0);"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /> fs ){<br />    </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 255);">float</span><span style="color: rgb(0, 0, 0);"> f:fs){<br />      System.</span><span style="color: rgb(0, 0, 255);">out</span><span style="color: rgb(0, 0, 0);">.println(f);<br />    }<br />    System.</span><span style="color: rgb(0, 0, 255);">out</span><span style="color: rgb(0, 0, 0);">.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">var count:</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> fs.length);<br />  }<br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> only one param can be var args,and should be placed at the end of param list   <br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">  public void printArgs(Integer<img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /> integers,String<img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /> objects  ){}</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);"><br />  </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">*<br />   * @param args<br />   </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />  </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> main(String[] args) {<br />    Varargs vars</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Varargs();<br />    vars.printObjectArgs(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Integer(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">),</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Integer(</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">),</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">abc</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />    vars.printFloats(</span><span style="color: rgb(0, 0, 0);">1.2f</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">1.3f</span><span style="color: rgb(0, 0, 0);">);<br />  }<br /><br />}<br /></span></div> </div> 杈撳嚭緇撴灉錛?br /><font style="background-color: rgb(222, 184, 135);">1<br />2<br />3<br />abc<br />var count:4<br />1.2<br />1.3<br />var count:2</font><img src ="http://www.aygfsteel.com/justfly/aggbug/12797.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/justfly/" target="_blank">Justfly Shi</a> 2005-09-12 23:17 <a href="http://www.aygfsteel.com/justfly/archive/2005/09/12/12797.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍏充簬java 5涓殑static import鐨勪竴鐐硅璁?/title><link>http://www.aygfsteel.com/justfly/archive/2005/09/11/12680.html</link><dc:creator>Justfly Shi</dc:creator><author>Justfly Shi</author><pubDate>Sun, 11 Sep 2005 12:15:00 GMT</pubDate><guid>http://www.aygfsteel.com/justfly/archive/2005/09/11/12680.html</guid><wfw:comment>http://www.aygfsteel.com/justfly/comments/12680.html</wfw:comment><comments>http://www.aygfsteel.com/justfly/archive/2005/09/11/12680.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/justfly/comments/commentRss/12680.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/justfly/services/trackbacks/12680.html</trackback:ping><description><![CDATA[<p align="left">鍦╦ava5涓坊鍔犵殑涓涓柊鐗規у氨鏄痵tatic import(闈欐佸鍏?)閫氳繃闈欐佸鍏ユ垜浠彲浠ュ緢鏂逛究鐨勪嬌鐢ㄥ湪鍏朵粬綾諱腑瀹氫箟鐨勫嚱鏁般傚涓嬮潰鐨勪唬鐮佹墍紺猴紝鎴戜滑鍙互鐩存帴鐨勪嬌鐢╦ava.lang.Math 鐨刴in鍜宮ax浠ュ強鍏朵粬鍦╦ava.lang.Math涓墍瀹氫箟鐨勯潤鎬佹柟娉曪紝鍙渶瑕佸湪import涓坊鍔犱竴鍙?font style="background-color: rgb(127, 255, 212);">import static java.lang.Math.*銆?/font>榪欐槸涓涓緢鏂逛究鐨勫姛鑳姐?br /><br /></p> <div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; background: rgb(230, 230, 230) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; width: 98%;"> <div><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" alt="" /><span style="color: rgb(0, 0, 0);">package cn.justfly.study.tiger;<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" alt="" /><br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" alt="" />import </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> java.lang.Math.max;<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" alt="" />import </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> java.lang.Math.min;<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" onclick="this.style.display='none'; Codehighlighter1_101_189_Open_Text.style.display='none'; Codehighlighter1_101_189_Closed_Image.style.display='inline'; Codehighlighter1_101_189_Closed_Text.style.display='inline';" id="Codehighlighter1_101_189_Open_Image" alt="" /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" onclick="this.style.display='none'; Codehighlighter1_101_189_Closed_Text.style.display='none'; Codehighlighter1_101_189_Open_Image.style.display='inline'; Codehighlighter1_101_189_Open_Text.style.display='inline';" style="display: none;" id="Codehighlighter1_101_189_Closed_Image" alt="" /></span><span style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);" id="Codehighlighter1_101_189_Closed_Text">/**/</span><span id="Codehighlighter1_101_189_Open_Text"><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">*<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" /> * Sample of Static Import<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" /> * @author Justfly Shi<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" /> * created at 2005-9-3 23:41:50<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" alt="" /> </span><span style="color: rgb(0, 128, 0);">*/</span></span><span style="color: rgb(0, 0, 0);"><br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" onclick="this.style.display='none'; Codehighlighter1_217_546_Open_Text.style.display='none'; Codehighlighter1_217_546_Closed_Image.style.display='inline'; Codehighlighter1_217_546_Closed_Text.style.display='inline';" id="Codehighlighter1_217_546_Open_Image" alt="" /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" onclick="this.style.display='none'; Codehighlighter1_217_546_Closed_Text.style.display='none'; Codehighlighter1_217_546_Open_Image.style.display='inline'; Codehighlighter1_217_546_Open_Text.style.display='inline';" style="display: none;" id="Codehighlighter1_217_546_Closed_Image" alt="" /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> StaticImport </span><span style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);" id="Codehighlighter1_217_546_Closed_Text"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_217_546_Open_Text"><span style="color: rgb(0, 0, 0);">{<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" /><br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" onclick="this.style.display='none'; Codehighlighter1_222_247_Open_Text.style.display='none'; Codehighlighter1_222_247_Closed_Image.style.display='inline'; Codehighlighter1_222_247_Closed_Text.style.display='inline';" id="Codehighlighter1_222_247_Open_Image" alt="" /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" onclick="this.style.display='none'; Codehighlighter1_222_247_Closed_Text.style.display='none'; Codehighlighter1_222_247_Open_Image.style.display='inline'; Codehighlighter1_222_247_Open_Text.style.display='inline';" style="display: none;" id="Codehighlighter1_222_247_Closed_Image" alt="" />  </span><span style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);" id="Codehighlighter1_222_247_Closed_Text">/**/</span><span id="Codehighlighter1_222_247_Open_Text"><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">*<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" />   * @param args<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" alt="" />   </span><span style="color: rgb(0, 128, 0);">*/</span></span><span style="color: rgb(0, 0, 0);"><br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" onclick="this.style.display='none'; Codehighlighter1_290_543_Open_Text.style.display='none'; Codehighlighter1_290_543_Closed_Image.style.display='inline'; Codehighlighter1_290_543_Closed_Text.style.display='inline';" id="Codehighlighter1_290_543_Open_Image" alt="" /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" onclick="this.style.display='none'; Codehighlighter1_290_543_Closed_Text.style.display='none'; Codehighlighter1_290_543_Open_Image.style.display='inline'; Codehighlighter1_290_543_Open_Text.style.display='inline';" style="display: none;" id="Codehighlighter1_290_543_Closed_Image" alt="" />  </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> main(String[] args) </span><span style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);" id="Codehighlighter1_290_543_Closed_Text"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_290_543_Open_Text"><span style="color: rgb(0, 0, 0);">{<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" onclick="this.style.display='none'; Codehighlighter1_295_416_Open_Text.style.display='none'; Codehighlighter1_295_416_Closed_Image.style.display='inline'; Codehighlighter1_295_416_Closed_Text.style.display='inline';" id="Codehighlighter1_295_416_Open_Image" alt="" /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" onclick="this.style.display='none'; Codehighlighter1_295_416_Closed_Text.style.display='none'; Codehighlighter1_295_416_Open_Image.style.display='inline'; Codehighlighter1_295_416_Open_Text.style.display='inline';" style="display: none;" id="Codehighlighter1_295_416_Closed_Image" alt="" />   </span><span style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);" id="Codehighlighter1_295_416_Closed_Text">/**/</span><span id="Codehighlighter1_295_416_Open_Text"><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"><br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" />    * min() and max() are defined in java.lang.Math as static method.<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" />    * but they can now be easily access.<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" alt="" />    * </span><span style="color: rgb(0, 128, 0);">*/</span></span><span style="color: rgb(0, 0, 0);"><br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" />   </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> min</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">min(</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">);<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" />   System.</span><span style="color: rgb(0, 0, 255);">out</span><span style="color: rgb(0, 0, 0);">.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">min is : </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">min);<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" />   </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> max</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">max(</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">);<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" />   System.</span><span style="color: rgb(0, 0, 255);">out</span><span style="color: rgb(0, 0, 0);">.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">max is : </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">max);<br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" /><br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" alt="" />  }</span></span><span style="color: rgb(0, 0, 0);"><br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" /><br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" alt="" />}</span></span><span style="color: rgb(0, 0, 0);"><br /><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" alt="" /></span></div> </div> <p><br />浣嗘槸榪欎釜鍔熻兘鍗翠笉鑳芥互鐢ㄣ傚洜涓哄畠浼氬鑷翠唬鐮佺殑鍙鎬у彉寰楀緢宸傝冭檻涓涓嬩竴涓湭鏇炬帴瑙﹁繃java.lang.Math綾葷殑璇昏呮潵鐪嬭繖孌典唬鐮併傚綋浠栬鍒?ldquo;int min=min(3,4)”錛屼粬浼氬緢榪鋒儜錛岃繖涓猰in鍑芥暟鍒板簳鏄湪鍝噷瀹氫箟鐨勫憿錛熶簬鏄粬灝卞緱鍘誨垎鏋恑mport榪欓噷銆傝繖孌典唬鐮佽繕濂借錛屽彧鏈変竴涓被琚潤鎬佸鍏ワ紝鍙渶瑕佹墦寮 java.lang.Math鐨勬枃妗e氨鍙互鐩存帴浜嗚В榪欎簺鏂規硶鐨勭浉鍏充俊鎭簡銆備絾鏄鏋滃悓鏃墮潤鎬佸鍏ヤ簡10涓被鐨勬儏鍐典笅鍛紵濡傛灉榪欎簺綾諱腑鏈夌潃鍚嶅瓧綾諱技錛堢浉鍚岋級浣嗘槸琛屼負鍗翠笉涓鑷寸殑鏂規硶鐨勬椂鍊欏憿錛熸瘮濡侾erson.eat(Food food)鍜?Animal.eat(Food food)銆?/p> <p>閭d箞榪欎釜鍔熻兘璇ュ浣曠敤鍛紵鎴戣涓?strong><font color="#008000">涓浜涘父鐢ㄧ殑宸ュ叿綾匯佸叏灞鍙橀噺綾葷瓑褰撻渶瑕佸湪涓涓被涓嬈′嬌鐢ㄧ殑鏃跺欏彲浠ュ榪涙潵</font></strong>錛屼絾鏄?font color="#ff0000">瀵逛簬緋葷粺涓殑<strike>妯″瀷綾?/strike>鎴栬呮槸<strike>鐢ㄧ殑嬈℃暟涓嶅鐨勫伐鍏風被</strike>榪樻槸涓嶈瀵煎叆鐨勫ソ</font>銆傛垜浠渶瑕佸湪鑷繁鍐欎唬鐮佹椂鐨勬柟渚垮拰浠g爜鏈韓鐨勫彲璇繪ч棿鍋氫釜鏉冭 銆?/p><img src ="http://www.aygfsteel.com/justfly/aggbug/12680.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/justfly/" target="_blank">Justfly Shi</a> 2005-09-11 20:15 <a href="http://www.aygfsteel.com/justfly/archive/2005/09/11/12680.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍩烘湰璇硶: Sample of autoboxing and unboxinghttp://www.aygfsteel.com/justfly/archive/2005/09/11/12651.htmlJustfly ShiJustfly ShiSat, 10 Sep 2005 18:07:00 GMThttp://www.aygfsteel.com/justfly/archive/2005/09/11/12651.htmlhttp://www.aygfsteel.com/justfly/comments/12651.htmlhttp://www.aygfsteel.com/justfly/archive/2005/09/11/12651.html#Feedback0http://www.aygfsteel.com/justfly/comments/commentRss/12651.htmlhttp://www.aygfsteel.com/justfly/services/trackbacks/12651.html瑕佹敞鎰忕殑鏄紝褰撹琚玼nboxing鐨勫皝瑁呯被涓簄ull鐨勬椂鍊欐垨鏈鍒濆鍖栨椂浼氭姏鍑轟竴涓猲ullpoint閿欒

package cn.justfly.study.tiger;

import java.util.ArrayList;
import java.util.Collection;

/**
 * Sample code of autoBoxing and auto-unboxing 
 * @author Justfly Shi
 * created at 2005-8-28 
 
*/

public class Boxing {

  
/**
   * @param args
   
*/

  
public static void main(String[] args) {
    Collection
<Integer> c = new ArrayList<Integer>();

    
for (int i = 0; i < 5; i++{
      c.add(i);
// autoboxing
    }

    System.
out.println("iterate with Interger");
    
for (Integer i : c) {

      System.
out.println(i + 100);// unboxing
    }


    System.
out.println("iterate with int");
    
for (int i : c)// unboxing in enhanced for
    {

      System.
out.println(i + 100);
    }

    
    Integer i
=null;
    
int j=i;//NullPointerException will be throw here
    System.out.println(j);
  }


}



]]>
主站蜘蛛池模板: 吉安市| 宝应县| 清徐县| 乐亭县| 温泉县| 黑龙江省| 汕尾市| 钟祥市| 登封市| 谷城县| 玉环县| 利津县| 安泽县| 济宁市| 神池县| 申扎县| 夏津县| 浮山县| 西畴县| 桑植县| 文昌市| 涞源县| 青海省| 沙洋县| 萨迦县| 泰来县| 宜昌市| 西城区| 金山区| 广饶县| 阜康市| 关岭| 建德市| 巴南区| 象州县| 镇远县| 铜梁县| 腾冲县| 文昌市| 江源县| 金山区|