Java: class , objects
Java: class , objects
1 Inheritance(¼Ì³Ð)µÄ¹Ø¼ü×Öextends
class MountainBike extends Bicycle {
}
µ«ÊDz»ÄܶàÖØ¼Ì³Ð¡£²»¹ý¿ÉÒÔͨ¹ýimplements¶à¸öinterfaceÀ´ÊµÏÖÀàËÆµÄ¶«Î÷
2 interface
interface Bicycle {
void changeCadence(int newValue); // wheel revolutions per minute
void changeGear(int newValue);
void speedUp(int increment);
void applyBrakes(int decrement);
}
class ACMEBicycle implements Bicycle {
// remainder of this class implemented as before
}
¿ÉʵÏÖ(implements)¶à¸öinterface
class MyClass extends MySuperClass implements YourInterface {
//field, constructor, and method declarations
}
means that MyClass is a subclass of MySuperClass and that it implements the YourInterface interface
3 package
A package is a namespace that organizes a set of related classes and interfaces.
4 Access Modifier
public, private, protected
public class Bicycle {
private int cadence;
public int aag;
public void test();
}
ÿ¸öfield»òmethod¶¼±ØÐëµ¥¶ÀÐÞÊÎ
Access Levels
ModifierClassPackageSubclassWorld
public
Y
Y
Y
Y
protected
Y
Y
Y
N
no modifier
Y
Y
N
N
private
Y
N
N
N
Ô¼¶¨£º
class Ãû×ֵĵÚÒ»¸ö×Öĸ´óд; methodµÚÒ»¸öwordÊǶ¯´Ê
5 Constructors
The compiler automatically provides a no-argument, default constructor for any class without constructors.
This default constructor will call the no-argument constructor of the superclass.
6 method & parameter
The Java programming language doesn't let you pass methods into methods. But you can pass an object into a method and then invoke the object's methods.
can Returning a Class or Interface??
7 this : current object
public class Point {
public int x = 0; //field¿ÉÒÔÕâÑù³õʼ»¯
public int y = 0;
Ïà¹ØÎĵµ£º
JAVAÓïÑÔÖеķ´Éä»úÖÆ£º
ÔÚJava ÔËÐÐʱ »·¾³ÖУ¬¶ÔÓÚÈÎÒâÒ»¸öÀ࣬ÄÜ·ñÖªµÀÕâ¸öÀàÓÐÄÄЩÊôÐԺͷ½·¨£¿
¶ÔÓÚÈÎÒâÒ»¸ö¶ÔÏó£¬ÄÜ·ñµ÷ÓÃËûµÄ·½·¨£¿ÕâЩ´ð°¸Êǿ϶¨µÄ£¬ÕâÖÖ¶¯Ì¬»ñÈ¡ÀàµÄÐÅÏ¢£¬ÒÔ¼°¶¯Ì¬µ÷ÓÃÀàµÄ·½·¨µÄ¹¦ÄÜÀ´Ô´ÓÚJAVAµÄ·´Éä¡£´Ó¶øÊ¹java¾ßÓж¯Ì¬ÓïÑÔµÄÌØÐÔ¡£
JA ......
¶þ ¶ÔÏó
ÀàʵÀý»¯¿ÉÉú³É¶ÔÏ󣬶ÔÏóͨ¹ýÏûÏ¢´«µÝÀ´½øÐн»»¥¡£ÏûÏ¢´«µÝ¼´¼¤»îÖ¸¶¨µÄij¸ö¶ÔÏóµÄ·½·¨ÒԸıäÆä״̬»òÈÃËü²úÉúÒ»¶¨µÄÐÐΪ¡£Ò»¸ö¶ÔÏóµÄÉúÃüÖÜÆÚ°üÀ¨Èý¸ö½×¶Î£ºÉú³É¡¢Ê¹ÓúÍÏû³ý¡£
¶ÔÏóµÄÇå³ý
¡¡¡¡ µ±²»´æÔÚ¶ÔÒ»¸ö¶ÔÏóµÄÒýÓÃʱ£¬¸Ã¶ÔÏó³ÉΪһ¸öÎÞÓöÔÏó¡£JavaµÄÀ¬»ø ......
Dojo ÔÚ»ùÓÚWeb µÄÓ¦ÓóÌÐòÖÐÔ½À´Ô½Êܵ½»¶Ó¡£ºÜ¶à¿ª·¢ÈËÔ±ÊÇ Java™ ±à³Ì·½ÃæµÄÄÜÊÖ£¬µ«ÊÇÔÚ JavaScript
·½ÃæÈ´È±·¦¾Ñé¡£´ÓÇ¿ÀàÐÍ¡¢ÃæÏò¶ÔÏóµÄ±àÒëÓïÑÔתÏò¶¯Ì¬µÄ¡¢ÈõÀàÐͽű¾ÓïÑÔ£¬¿ª·¢ÈËÔ±ÐèÒª¾Àú¸ÅÄîԾǨ´øÀ´µÄÀ§ÄÑ¡£ÕâÖÖ»ìÂÒʹ¿ª·¢ÈËÔ±ºÜÄÑÕýÈ·µØÉùÃ÷
Dojo Àà¡£±¾ÎĽ«°ïÖúÊáÀíÕâÖÖ»ìÂÒ£¬½âÊÍΪºÎ±ØÐë ......
Ò»¡¢Ê²Ã´ÊÇJavaÐéÄâ»ú
JavaÐéÄâ»úÊÇÒ»¸öÏëÏóÖеĻúÆ÷,ÔÚʵ¼ÊµÄ¼ÆËã»úÉÏͨ¹ýÈí¼þÄ£ÄâÀ´ÊµÏÖ¡£JavaÐéÄâ»úÓÐ×Ô¼ºÏëÏóÖеÄÓ²¼þ,Èç´¦ÀíÆ÷¡¢¶ÑÕ»¡¢¼Ä´æÆ÷µÈ,»¹¾ßÓÐÏàÓ¦µÄÖ¸Áîϵͳ¡£
1.ΪʲôҪʹÓÃJavaÐéÄâ»ú
JavaÓïÑÔµÄÒ»¸ö·Ç³£ÖØÒªµÄÌØµã¾ÍÊÇÓëÆ½Ì¨µÄÎÞ¹ØÐÔ¡£¶øÊ¹ÓÃJavaÐéÄâ»úÊÇʵÏÖÕâÒ»ÌØµãµÄ¹Ø¼ü¡£Ò»°ãµÄ¸ß¼¶ÓïÑÔÈç¹ ......
Éî¿ÌÀí½âJava±à³ÌµÄ7¸öÀý×Ó Ù¡Ç¿ 2009Äê11ÔÂ7ÈÕ http://blog.csdn.net/microtong
1. ÔĶÁÏÂÁдúÂë»Ø´ðÎÊÌ⣨µÚÒ»¸öJava³ÌÐò£¬Àí½âPATHºÍCLASSPATH£¬Ñ§»áʹÓÃjavacºÍjavaÃüÁ
view plaincopy to clipboardprint?
package cn.edu.uibe;
public class HelloWorld {
......