Android vs Java
Java yog ib qho ntawm cov khoom siv nrov tshaj plaws los qhia cov lus hauv ntiaj teb. Java yog siv ntau rau software thiab txhim kho lub vev xaib. Tsis ntev los no, Java tau dhau los ua hom lus nrov rau cov ntawv thov mobile thiab. Android yog lub xov tooj ntawm tes raws li platform tsim los ntawm Google. Kev txhim kho Android feem ntau yog java-based. Feem ntau ntawm Java cov tsev qiv ntawv muaj nyob hauv Android platform, tab sis muaj ntau lwm cov tsev qiv ntawv (tsis yog java) uas muaj nyob hauv Android (rau cov neeg siv interfaces, thiab lwm yam) ib yam nkaus.
Java
Java yog ib qho ntawm cov khoom siv dav siv ntau tshaj plaws (thiab chav kawm-raws li) programming lus siv rau kev txhim kho software rau kev txhim kho lub vev xaib, niaj hnub no. Nws yog lub hom phiaj dav dav thiab cov lus programming ib txhij. Nws yog Ameslikas tsim los ntawm Sun Microsystems hauv 1995. James Gosling yog leej txiv ntawm Java programming lus. Oracle Corporation tam sim no muaj Java (tom qab yuav Sun Microsystems tsis ntev los no). Java Standard Edition 6 yog nws qhov kev tso tawm ruaj khov tam sim no. Java yog hom lus uas muaj zog heev uas txhawb nqa ntau lub platform los ntawm Windows mus rau UNIX. Java muaj ntawv tso cai raws li GNU General Public License. Java's syntax zoo ib yam li C thiab C ++. Java cov ntaub ntawv muaj qhov.java extension. Tom qab sau Java cov ntaub ntawv siv javac compiler, nws yuav tsim cov ntaub ntawv.class (muaj Java bytecode). Cov ntaub ntawv bytecode no tuaj yeem txhais tau siv JVM (Java Virtual Machine). Txij li thaum JVM tuaj yeem khiav ntawm txhua lub platform, Java tau hais tias yog ntau lub platform (hla-platform) thiab portable heev. Feem ntau, cov neeg siv kawg siv JRE (Java runtime Ib puag ncig) los khiav Java bytecode (lossis Java Applets ntawm web browsers). Cov tsim software siv Java Development Kit (JDK) rau kev txhim kho daim ntawv thov. Qhov no yog ib qho superset ntawm JRE, uas suav nrog lub compiler thiab debugger. Ib qho zoo ntawm Java yog nws cov khoom siv khib nyiab tsis siv neeg, qhov twg cov khoom uas tsis tas yuav raug tshem tawm ntawm lub cim xeeb cia li.
Android
Android yog lub xov tooj txawb platform tsim los ntawm Google. Ib feem loj ntawm Java 5.0 cov tsev qiv ntawv tau txais kev txhawb nqa hauv Android. Yog li, nws tuaj yeem hais tias kev txhim kho Android yog java-based. Ntau lub tsev qiv ntawv Java uas tsis tau txais kev txhawb nqa yog muaj kev hloov pauv zoo dua (lwm cov tsev qiv ntawv zoo sib xws) lossis tsuas yog tsis xav tau (xws li cov tsev qiv ntawv luam ntawv, thiab lwm yam). Cov tsev qiv ntawv zoo li java.awt thiab java.swing tsis txaus siab vim tias Android muaj lwm lub tsev qiv ntawv rau cov neeg siv interfaces. Android SDK txhawb nqa lwm lub tsev qiv ntawv thib peb xws li org.blues (Bluetooth txhawb nqa). Thaum kawg, Android code tau muab tso ua ke rau hauv Dalvik opcodes. Davilk yog lub tshuab virtual tshwj xeeb ua kom zoo rau cov khoom siv txawb nrog cov peev txheej tsawg xws li lub zog, CPU thiab nco.
Qhov txawv ntawm Android thiab Java yog dab tsi?
Java yog hom lus programming, thaum Android yog lub xov tooj ntawm tes. Kev txhim kho hauv Android yog java-based (feem ntau ntawm lub sijhawm), vim tias feem ntau ntawm Java cov tsev qiv ntawv tau txais kev txhawb nqa hauv Android. Txawm li cas los xij, muaj qhov sib txawv tseem ceeb. Tsis zoo li Java, Android daim ntawv thov tsis muaj lub luag haujlwm tseem ceeb. Lawv muaj onCrete, onResume, onPause thiab onDestroy functions uas yuav tsum tau overwritten los ntawm developers. Java code compiles rau Java bytecode, thaum Android code compiles rau Davilk opcode.