HTML5¼¼Êõ

¡¾java¡¿¹ØÓÚjavaÀàºÍ¶ÔÏó£¬ÄãÏëÖªµÀµÄÔÚÕâÀ - ÍâÆŵÄÅíºþÍå(2)

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2017-09-17 14:05 ÎÒÒªÆÀÂÛ( )

public class Test { main(String args []) { People people1 = new People(); people1.print( , ); }} Êä³ö£º ÎÒµ÷ÓÃÁËÁ½¸ö²ÎÊýµÄ·½·¨£¡ Èç¹û½«Test.javaÖеÄÓï¾ä»»³É£º main(String args []) { People people1 =

public class Test {    main(String args []) {    People people1 = new People();    people1.print(, );    } }

 

Êä³ö£º

ÎÒµ÷ÓÃÁËÁ½¸ö²ÎÊýµÄ·½·¨£¡

 

Èç¹û½«Test.javaÖеÄÓï¾ä»»³É£º

main(String args []) {    People people1 = new People();    people1.print(); }

 

Êä³ö£º

ÎÒµ÷ÓÃÁËÒ»¸ö²ÎÊýµÄ·½·¨£¡

 

 

¡¾×¢Òâ¡¿º¯ÊýÖØÔØÖ»ºÍ²ÎÊýÀàÐͺͲÎÊý¸öÊýÓйأ¬ºÍ·µ»ØÖµÀàÐÍÎ޹أ¡£¡ ÀýÈçpublic void XXX()ºÍpublic String XXX()²»¹¹³ÉÖØÔØ£¡ £¨ÕâÒ²µ±È»»á±¨´í£¬ÒòΪÁ½¸öº¯ÊýÖظ´ÁË£©Í¬Ê±ÖØÔØÒ²ºÍ²ÎÊýµÄÃüÃûÎ޹أ¬ public void XXX(String str1)ºÍ public void XXX(String str2)ÊÇͬһ¸öº¯Êý£¬ÕâºÍº¯ÊýÖØÔؾ͸üûÓÐëÏß¹ØϵÁË

 

¹¹Ô캯ÊýÖØÔØ

 

ºÍº¯ÊýÖØÔصÄÌØÐÔÒ»Ö£¬µ«ÓÐÒ»¸öÓÐȤµÄÒ»µãҪעÒ⣺ µ±ÄãûÓÐдÈë¹¹Ô캯ÊýµÄʱºò£¬ÏµÍ³»áĬÈÏÌṩһ¸öÎ޲εĹ¹Ô캯Êý¸øÄ㣬 ËùÒÔ¾ÍËãûÓÐÏÔʽµØдtype ʵÀý = new type()Ò²ÊdzÉÁ¢µÄ

 

µ«ÊÇ£¡ µ±ÄãдÁËÒ»¸öÓвÎÊýµÄ¹¹Ô캯Êý£¬µ«ÓÖûÓÐдÎÞ²ÎÊýµÄ¹¹Ô캯Êýʱ£¬type ʵÀý = new type()¾Í»á±¨´íÁË£¡£¨ÒòΪĬÈϵÄÎ޲ι¹Ô캯ÊýÒѾ­±»ÄãдµÄÓвÎÊýµÄ¹¹Ô캯Êý¸øÈ¡´úÁËÂï~~~~£©

 

 

ʵÀý±äÁ¿µÄĬÈÏÖµ£¬ºÍ³õʼ»¯ÊµÀý±äÁ¿

 

Èç¹ûÄãÉùÃ÷ÁËÒ»¸öʵÀý±äÁ¿£¬µ«Ã»Óгõʼ»¯Ëü£¬ÄÇôÕâ¸ö±äÁ¿»áÈ¡µÃÒ»¸öĬÈÏÖµ£¬Ä¬ÈÏÖµÒÀÀàÐ;ö¶¨£º

ÕâÊÇÿ¸ö»ù±¾ÀàÐͶÔÓ¦µÄĬÈÏÖµ

boolean        (null)                   0 long               0 £¨L£© float               0.0 £¨f£© double           0.0 £¨d£©

 

 

¶ÔÓÚÒýÓÃÀàÐÍ£¬Ò»Âɳõʼ»¯Îªnull

 

Àý×Ó£º

Default.java:

public class Default {    private  int number;    private float f;    private boolean bool;    private char c;    private byte b;    public void printDefaultValues () {    System.+ number);    System.+ f);    System.+ bool);    System.+ c);    System.+ b);    } }

 

 

Test.java:

public class Test {    main(String args []) {    Default default1 = new Default();    default1.printDefaultValues();    } }

 

Êä³ö

intµÄĬÈÏÖµ:0 floatµÄĬÈÏÖµ:0.0 booleanµÄĬÈÏÖµ:false charµÄĬÈÏÖµ:

 

Ò»°ãÇé¿öÏ£¬×îºÃ¶ÔÒ»¸öʵÀý±äÁ¿½øÐгõʼ»¯£¬È¥¸²¸ÇµôĬÈÏÖµ

public class Default {    private  int number = 1; }

 

·ÃÎÊ˽ÓÐʵÀý±äÁ¿

˽ÓбäÁ¿µÄ·ÃÎÊ·½Ê½ÎÒ·Ö³ÉÁ½ÖÖ£º ÀàÄÚ·ÃÎʺÍʵÀý·ÃÎÊ

£¨Êµ¼ÊÉÏÁ½Õ߸ÅÄîÉÏÓн»²æ£¬µ«ÎªÁË·½±ã˵Ã÷ÎÒ½«Á½Õß·Ö¿ªÁË£©

 

ÀàÄÚ·ÃÎÊ£ºÔÚ¶¨ÒåÒ»¸öÀàµÄʱºò£¬ÔÚÀàÄÚ²¿·ÃÎÊ˽ÓбäÁ¿

ʵÀý·ÃÎÊ£º ´´½¨¶ÔÓ¦ÀàµÄÒ»¸ö¶ÔÏó£¬Í¨¹ý¶ÔÏó·ÃÎÊ

 

ʵÀý·ÃÎÊ

´´½¨µÄ¶ÔÏó²»ÄÜÖ±½Ó·ÃÎÊ˽ÓÐʵÀý±äÁ¿£¬µ«ÄÜͨ¹ý¹«ÓеķÃÎÊÆ÷·½·¨·ÃÎÊ£º

ÀýÈ磺

 

People.java:

public class People {    private String name;    public People (String aName) {    name = aName;    }    public String getName () {    return name;    } }

 

ÔÚTest.javaÖУ¬Èç¹ûÎÒÃÇÊÔͼֱ½Óͨ¹ýPeopleµÄʵÀý¶ÔÏó·ÃÎÊname˽ÓбäÁ¿£º

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • ¡¾Java IOÁ÷¡¿×Ö½ÚÁ÷ºÍ×Ö·ûÁ÷Ïê½â - ÔÆ¿ªµÄÁ¢ÏÄ

    ¡¾Java IOÁ÷¡¿×Ö½ÚÁ÷ºÍ×Ö·ûÁ÷Ïê½â - ÔÆ¿ªµÄÁ¢ÏÄ

    2017-09-15 15:06

  • thisµÄÓ÷¨ ¨C JavaScriptÉîÈëdz³ö£¨¶þ£© - OkayChen

    thisµÄÓ÷¨ ¨C JavaScriptÉîÈëdz³ö£¨¶þ£© - OkayChen

    2017-09-15 12:00

  • JavaScript: ʹÓà atan2 À´»æÖÆ ¼ýÍ· ºÍ ÇúÏß - ¾È»ð¶Ó³¤

    JavaScript: ʹÓà atan2 À´»æÖÆ ¼ýÍ· ºÍ ÇúÏß - ¾È»ð¶Ó³¤

    2017-09-14 08:04

  • ´óÁä³ÌÐòÔ±Èâ·­¼Ç¼¡¾Ò»¡¿ - JavaNerd

    ´óÁä³ÌÐòÔ±Èâ·­¼Ç¼¡¾Ò»¡¿ - JavaNerd

    2017-09-13 09:01

ÍøÓѵãÆÀ
í