JavaÃæÊÔÌâ¼°´ð°¸£¨´úÂëÌâ19µÀ£©
JAVA´úÂë²é´í
1.
abstract class Name {
private String name;
public abstract boolean isStupidName(String name) {}
}
´óÏÀÃÇ£¬ÕâÓкδíÎó?
´ð°¸: ´í¡£abstract method±ØÐëÒԷֺŽá⣬ÇÒ²»´ø»¨À¨ºÅ¡£
2.
public class Something {
void doSomething () {
private String s = "";
int l = s.length();
}
}
ÓдíÂð?
´ð°¸: ´í¡£¾Ö²¿±äÁ¿Ç°²»ÄÜ·ÅÖÃÈκηÃÎÊÐÞÊηû (private£¬public£¬ºÍprotected)¡£final¿ÉÒÔÓÃÀ´ÐÞÊξֲ¿±äÁ¿
(finalÈçͬabstractºÍstrictfp£¬¶¼ÊÇ·Ç·ÃÎÊÐÞÊηû£¬strictfpÖ»ÄÜÐÞÊÎclassºÍmethod¶ø·Çvariable)¡£
3.
abstract class Something {
private abstract String doSomething ();
}
ÕâºÃÏñûʲô´í°É?
´ð°¸: ´í¡£abstractµÄmethods²»ÄÜÒÔprivateÐÞÊΡ£abstractµÄmethods¾ÍÊÇÈÃ×ÓÀàimplement(ʵÏÖ)¾ßÌåϸ½ÚµÄ£¬Ôõô¿ÉÒÔÓÃprivate°Ñabstract
method·âËøÆðÀ´ÄØ? (ͬÀí£¬abstract methodÇ°²»ÄܼÓfinal)¡£
4.
public class Something {
public int addOne(final int x) {
return ++x;
}
}
Õâ¸ö±È½ÏÃ÷ÏÔ¡£
´ð°¸: ´í¡£int x±»ÐÞÊγÉfinal£¬Òâζ×Åx²»ÄÜÔÚaddOne methodÖб»Ð޸ġ£
5.
public class Something {
public static void main(String[] args) {
Other o = new Other();
new Something().addOne(o);
}
public void addOne(final Other o) {
o.i++;
}
}
class Other {
public int i;
}
ºÍÉÏÃæµÄºÜÏàËÆ£¬¶¼ÊǹØÓÚfinalµÄÎÊÌ⣬ÕâÓдíÂð?
´ð°¸: ÕýÈ·¡£ÔÚaddOne methodÖУ¬²ÎÊýo±»ÐÞÊγÉfinal¡£Èç¹ûÔÚaddOne methodÀïÎÒÃÇÐÞ¸ÄÁËoµÄreference
(±ÈÈç: o = new Other();)£¬ÄÇôÈçͬÉÏÀýÕâÌâÒ²ÊÇ´íµÄ¡£µ«ÕâÀïÐ޸ĵÄÊÇoµÄmember vairable
(³ÉÔ±±äÁ¿)£¬¶øoµÄreference²¢Ã»Óиı䡣
6.
class Something {
int i;
public void doSomething() {
&nb
Ïà¹ØÎĵµ£º
ÔÚËùÓеÄJavaÊé¼®µ±ÖУ¬Æäʵ×î×îÓÐÓõģ¬²¢²»ÊÇO′reillyµÄ Java Serials£¬ÕæÕý×î×îÓÐÓô¦ÊÇJDKµÄÎĵµation£¡¼¸ºõÄãÏë»ñµÃµÄËùÓеÄ֪ʶÔÚÎĵµationÀïÃæÈ«²¿¶¼ÓУ¬ÆäÖÐ×îÖ÷ÒªµÄ²¿·Öµ±È»ÊÇJava»ù´¡Àà¿âµÄAPIÎĵµ£¬ÊÇ°´ÕÕpackageÀ´×éÖ¯µÄ£¬¶ÔÓÚÿһ¸öclass¶¼ÓÐÏêϸµÄ½âÊÍ£¬ËüµÄ¼Ì³Ð¹Øϵ£¬ÊÇ·ñʵÏÖÁËij¸ö½Ó¿Ú£¬Í¨³£ÓÃÔÚÄÄÐ ......
ѧϰJava±Ø¿´ - JAVA´úÂë±àдµÄ30Ìõ½¨Òé
(1) ÀàÃûÊ××ÖĸӦ¸Ã´óд¡£×ֶΡ¢·½·¨ÒÔ¼°¶ÔÏ󣨾ä±ú£©µÄÊ××ÖĸӦСд¡£¶ÔÓÚËùÓбêʶ·û£¬ÆäÖаüº¬µÄËùÓе¥´Ê¶¼Ó¦½ô¿¿ÔÚÒ»Æ𣬶øÇÒ´óдÖм䵥´ÊµÄÊ××Öĸ¡£ÀýÈ磺
ThisIsAClassName
thisIsMethodOrFieldName
ÈôÔÚ¶¨ÒåÖгöÏÖÁ˳£Êý³õʼ»¯ ......
ÔÚ²âÊÔ
ConsoleRunner
µÄ¹ý³ÌÖз¢ÏÖÒ»¸öÓÐÒâ˼µÄÏÖÏó£¬Ò»¶ÎºÜ¼òµ¥µÄ
C
³ÌÐò£º
#include <stdio.h>
#include <windows.h>
int main() {
int i = 0;
for (;;) {
printf("%d\n", i++); ......
¿ìÅÅ£º¿ìËÙÅÅÐò£¬ÄѶȲ»ÊÇÌ«´ó£¬µ«ÊÇÊÇÎÒ¾³£°ÑÍæµÄС´úÂëÖ®Ò»£¬ÒýÓÿìÅÅ´úÂ봴ʼÈ˵ÄÒ»¾ä»°“Òª²»ÊǼòÁ·ÓÖÃ÷ÏÔûÓдíÎó£¬Òª²»ÊǸ´ÔÓûÓÐÃ÷ÏԵĴíÎó”
ÆðÒò£º
Ö÷ÒªÊÇÇ°Ò»Õó¿´ÁõÈê¼ÑµÄ¡¶Ëã·¨ÒÕÊõÓëÐÅϢѧ¾ºÈü¡·P73Ò³£¬ÅöÇÉÎÒÓÖÇ×ÊÖдÁËÒ»±éÄÇÊéÉϵIJâÊÔÁËһϣ¬·¢ÏÖ¾¹È»ÊÇ´íÎóµÄ£¬È»ºóÎÒÓÖ²âÊÔÁËÒ»ÏÂÎÒÒÔÇ ......
JAVAºÍC++¶¼ÊÇÃæÏò¶ÔÏóÓïÑÔ¡£Ò²¾ÍÊÇ˵£¬ËüÃǶ¼Äܹ»ÊµÏÖÃæÏò¶ÔÏó˼Ï루·â×°£¬¼Ì³Ë£¬¶à̬£©¡£¶øÓÉÓÚc++ΪÁËÕչ˴óÁ¿µÄCÓïÑÔʹÓÃÕߣ¬¶ø¼æÈÝÁËC£¬Ê¹µÃ×ÔÉí½ö½ö³ÉΪÁË´øÀàµÄCÓïÑÔ£¬¶à¶àÉÙÉÙÓ°ÏìÁËÆäÃæÏò¶ÔÏóµÄ³¹µ×ÐÔ£¡JAVAÔòÊÇÍêÈ«µÄÃæÏò¶ÔÏóÓïÑÔ£¬Ëü¾ä·¨¸üÇåÎú£¬¹æÄ£¸üС£¬¸üÒ×ѧ¡£ËüÊÇÔÚ¶Ô¶àÖÖ³ÌÐòÉè¼ÆÓïÑÔ½øÐÐÁËÉîÈëϸÖÂÑо¿µ ......