Java±ä³¤²ÎÊý
ÔÚJava5ÖÐÌṩÁ˱䳤²ÎÊý£¬Ò²¾ÍÊÇÔÚ·½·¨¶¨ÒåÖпÉÒÔʹÓøöÊý²»È·¶¨µÄ²ÎÊý£¬¶ÔÓÚͬһ·½·¨¿ÉÒÔʹÓò»Í¬¸öÊýµÄ²ÎÊýµ÷Óã¬ÀýÈ磺print("hello");print("hello","lisi");print("hello","ÕÅÈý");ÏÂÃæ½éÉÜÈçºÎ¶¨Òå¿É±ä³¤²ÎÊýÒÔ¼°ÈçºÎʹÓÿɱ䳤²ÎÊý¡£
1¡¢¿É±ä³¤²ÎÊý·½·¨µÄ¶¨Òå
ʹÓÃ...±íʾ¿É±ä³¤²ÎÊý£¬ÀýÈç
print(String... args){
...
}
ÔÚ¾ßÓпɱ䳤²ÎÊýµÄ·½·¨ÖпÉÒ԰ѲÎÊýµ±³ÉÊý×éʹÓã¬ÀýÈç¿ÉÒÔÑ»·Êä³öËùÓеIJÎÊýÖµ¡£
print(String... args){
for(String temp:args)
System.out.println(temp);
}
2¡¢¿É±ä³¤²ÎÊýµÄ·½·¨µÄµ÷ÓÃ
µ÷ÓõÄʱºò¿ÉÒÔ¸ø³öÈÎÒâ¶à¸ö²ÎÊý£¬ÀýÈ磺
print("hello");
print("hello","lisi");
print("hello","ÕÅÈý");
3¡¢×¢ÒâÊÂÏî
3.1 ÔÚµ÷Ó÷½·¨µÄʱºò£¬Èç¹ûÄܹ»ºÍ¹Ì¶¨²ÎÊýµÄ·½·¨Æ¥Å䣬ҲÄܹ»Óë¿É±ä³¤²ÎÊýµÄ·½·¨Æ¥Å䣬ÔòÑ¡Ôñ¹Ì¶¨²ÎÊýµÄ·½·¨¡£¿´ÏÂÃæ´úÂëµÄÊä³ö£º
package ch6;
import static java.lang.System.out;
public class VarArgsTest {
public static void main(String[] args) {
VarArgsTest test = new VarArgsTest();
test.print("hello");
test.print("hello","zhangsan");
}
public void print(String... args){
for(int i=0;i<args.length;i++){
out.println(args[i]);
}
}
public void print(String test){
out.println("----------");
}
}
3.2 Èç¹ûÒªµ÷Óõķ½·¨¿ÉÒÔºÍÁ½¸ö¿É±ä²ÎÊýÆ¥Å䣬Ôò³öÏÖ´íÎó£¬ÀýÈçÏÂÃæµÄ´úÂ룺
package ch6;
import static java.lang.System.out;
public class VarArgsTest {
public static void main(String[] args) {
VarArgsTest test = new VarArgsTest();
test.print("hello");
test.print("hello","zhangsan");
}
public void print(String... args){
for(int i=0;i<args.length;i++){
out.println(args[i]);
}
}
public void print(String test,String...args ){
out.println("----------");
}
}
¶ÔÓÚÉÏÃæµÄ´úÂ룬main·½·¨ÖеÄÁ½¸öµ÷Óö¼²»ÄܱàÒëͨ¹ý¡£
3.3 Ò»
Ïà¹ØÎĵµ£º
ͨ³£Çé¿öÏ£¬ÎÒÃÇÔÚ±àдjavaÎļþʱ£¬»áÓÐÒýÓõ½×ÔÒѶ¨ÒåµÄһЩÀ࣬Èç¹û°´Í¨³£µÄjavac *.javaµÄÐÎʽÀ´±àÒë»á³öÏÖÕÒ²»µ½·ûºÅµÄ´íÎó¡£
ÒÔÏÂÌṩÁËÁ½ÖÖ·½·¨£¬ÒÔ¹©²Î¿¼
¼ÙÈçÔÚd:\web\wshÏÂÓÐa.javaºÍb.javaÁ½¸öÎļþ£¬ÔÚb.javaÎļþÖÐÓÐÒýÓÃÁËa.java¡£ÏÂÃæÊDZàÒëµÄ·½·¨
·½·¨Ò»:
½øÈëd:\web\wshÏ£º javac a.java
È»ºóÍ˳öwshÄ ......
ת×Ô£ºhttp://java.mblogger.cn/sadfasfasd/
×òÌì¸ãÁ˶¯Ì¬×Ô¶¯¼ÓÔØÅäÖÃÎļþ£¬ÓÖÓöµ½Â·¾¶ÎÊÌ⣬ÕÒµ½ÕâƪºÜ°ôµÄÎÄÕ£¬ÊÕ²Øһϣ¬À´×Ô
http://java.chinaitlab.com/base/532062_3.html http://www.blogjava.net/killme2008/archive/2007/06/08/122758.html
Ç ......
1¡¢±ØÐëÒýÈ룺java.text.SimpleDateFormat
2¡¢ÉèÖÃÏÔʾ·½Ê½£¬µ÷ÓÃformat¸ñʽ¡£
SimpleDateFormat sdf=new SimpleDateFormat("yyyyÄêMMÔÂddÈÕ");
String date=sdf.format(blog.getCreatedTime());
sdf=new Simp ......
1.±È½Ïºó£¬·µ»Ø0,1,-1 µÄ½á¹û£¬¿ÉÒÔÓÃ
return (thisVal<anotherVal ? -1 : (thisVal==anotherVal ? 0 : 1));
ЧÂʸü¸ß
ÒÔÏÂת×Ô http://bluelzx.javaeye.com/blog/200987
1.
Á½ÖֱȽϽӿڷÖÎö
ÔÚ
“
¼¯ºÏ¿ò¼Ü
”
ÖÐÓÐÁ½ÖֱȽϽӿڣº
Comparable
½Ó¿ÚºÍ
Comparator
½Ó¿Ú¡£
Compara ......
¡¾×ª¡¿JavaÖеÄλÔËËã·û
Ô×÷ÕߣºRosen Jiang ³ö´¦£ºhttp://www.blogjava.net/rosen
ÒÆλÔËËã·û
°üÀ¨£º
“>> ÓÒÒÆ”£»“<< ×óÒÆ”£»“>>> ÎÞ·ûºÅÓÒÒÆ”
Àý×Ó£º
-5>>3=-1
1111 1111 1111 1111 1111 1111 1111 ......