Cov txheej txheem:

Basic Java Debugging: 9 Kauj Ruam
Basic Java Debugging: 9 Kauj Ruam

Video: Basic Java Debugging: 9 Kauj Ruam

Video: Basic Java Debugging: 9 Kauj Ruam
Video: How To Debug Java Code The Right Way - Eclipse Debugger Full Tutorial 2024, Kaum ib hlis
Anonim
Basic Java Debugging
Basic Java Debugging

Phau ntawv qhia no qhia txog cov kauj ruam yooj yim los ntawm kev txheeb xyuas rau Java ua yuam kev. Phau ntawv qhia no tsis muab kev pabcuam hauv kev teeb tsa java programming software thiab cia siab tias koj twb tau ua tiav txoj haujlwm no ua ntej ua ntej. Txog qhov siv tau zoo tshaj plaws ntawm phau ntawv qhia no, rov qab los rau nws thaum muaj qhov ua yuam kev uas koj tsis paub meej txog thiab txheeb xyuas los ntawm 8 qhov ua tau zoo txog thaum koj tau ntsib nrog kev daws teeb meem lossis mus txog qhov kawg. Nco ntsoov, cov piv txwv no yog txhua yam yooj yim thiab muaj lub ntsiab lus rau kev txhawb nqa pib.

Ua ntej koj pib tshuaj xyuas los ntawm txhua qhov kev daws teeb meem, ua tibzoo saib qhov yuam kev uas Java tau ceeb toom rau koj nrog. Txhua kauj ruam yuav pib los ntawm kev ua kom pom qhov yuam kev uas nws cuam tshuam nrog.

Kauj Ruam 1: “Syntax Error, Insert”; kom ua tiav BlockStatements"

"Syntax yuam kev, ntxig"; " kom ua tiav BlockStatements "
"Syntax yuam kev, ntxig"; " kom ua tiav BlockStatements "

Nov yog qhov yooj yim tshaj plaws ntawm Syntax yuam kev, nws yooj yim txhais tau tias koj tsis nco qab lub semicolon thaum kawg ntawm koj cov lus. Txhua qhov kev tshaj tawm thiab cov lus tshaj tawm yuav xaus nrog tus lej cim. Hauv qee qhov xwm txheej xws li yog tias yog, lwm qhov, thiab rau nqe lus koj yuav tsis tas yuav tso tus lej semicon.

Kauj Ruam 2: "tsis tuaj yeem daws qhov hloov pauv", lossis "ntxig VariableDeclarators"

"Tsis tuaj yeem raug daws rau qhov hloov pauv", lossis "ntxig VariableDeclarators"
"Tsis tuaj yeem raug daws rau qhov hloov pauv", lossis "ntxig VariableDeclarators"

Qhov Syntax yuam kev no tshwm sim thaum koj tab tom sim siv qhov sib txawv yam tsis tau tsim nws ua ntej lossis muab nws hom ntaub ntawv. Cias ntxiv cov hom ntaub ntawv uas cuam tshuam nrog koj qhov sib txawv, piv txwv tuaj yeem yog "int", "boolean", "char", thiab "double".

Kauj Ruam 3: "ntxig"} "Ua kom tiav ClassBody"

"Ntxig"} "Ua kom tiav ClassBody
"Ntxig"} "Ua kom tiav ClassBody

Peb tom ntej Syntax yuam kev tau ua nrog cov kab xev. Koj yuav nquag pom qhov ua yuam kev tshwm sim thaum koj tau plam ib qho lossis ob qho tib si nkhaus nkhaus. Yog tias koj ploj lawm ob qho koj yuav pom qhov ua yuam kev, "ntxig" ClassBody "kom ua tiav ClassDeclaration". Yog tias tsuas yog ib qho ploj lawm koj yuav pom qhov yuam kev, "ntxig"} "kom ua tiav ClassBody" lossis "{xav tau tom qab tus cim no". Qhov ua yuam kev feem ntau yuav tshwm sim ntawm kab yog lub qhov nkhaus tuaj yeem muab tso rau txhawm rau txhim kho.

Kauj ruam 4: Infinite Loop

Infinite Loop
Infinite Loop

Tam sim no peb saib ntawm rooj plaub uas qhov yuam kev feem ntau yuav tsis muab los ntawm Java tus thov kev pab. Qhov no tshwm sim thaum koj muaj lub voj xws li lub voj voos lossis lub voj uas ua voj voos tas mus li. Tsis muaj cov lus teb yooj yim rau kev daws teeb meem vim tias txhua tus neeg txoj cai yuav sib txawv tab sis sim ntxiv phau ntawv qhia txwv ntxiv hauv txoj cai yuav tsum yog lub hom phiaj tseem ceeb. Tom qab qhov kev sim los txheeb xyuas vim li cas koj cov cai tsis tuaj yeem ua tau raws li koj qhov kev puas tsuaj tawg?

Kauj Ruam 5: "Tsis tuaj yeem daws rau hom"

"Tsis tuaj yeem daws rau hom"
"Tsis tuaj yeem daws rau hom"
"Tsis tuaj yeem daws rau hom"
"Tsis tuaj yeem daws rau hom"

Qhov Syntax yuam kev no tau ua nrog kev xa khoom. Thaum twg los xij peb xav siv API los ntawm lwm chav kawm, peb yuav tsum xa cov chav kawm mus rau tam sim no. Ib qho tshwm sim tshwm sim rau qhov no yog kev siv Scanner ua haujlwm, txhawm rau siv nws koj yuav tsum ntshuam chav kawm "java.util. Scanner". Nco ntsoov qhov no tsuas yog piv txwv.

Kauj Ruam 6: “Txoj Hauv Kev” “Tsis Txaus Siab Rau Hom”

"Txoj Kev" "Tsis tau txhais rau Hom"
"Txoj Kev" "Tsis tau txhais rau Hom"

Qhov Syntax yuam kev no tshwm sim thaum peb tsis nco qab lub npe kawm thaum lub sijhawm hu xov tooj. Thawj qhov piv txwv rau qhov no yuav yog thaum twg peb sim luam tawm. Yog tias koj yog ib tus neeg uas tab tom tawm ntawm cov lus uas siv cov ntawv yooj yim () ua haujlwm ces qhov no tuaj yeem tshwm sim ntau zaus. Koj yuav xav siv System.out.print () lossis System.out.println (). Qhov no yuav tshwm sim ib txwm thaum hu xov tooj.

Kauj Ruam 7: "Cov kab ntawv tsis raug kaw los ntawm ob-nqe lus"

"Txoj hlua Literal Tsis raug kaw los ntawm ob-nqe lus"
"Txoj hlua Literal Tsis raug kaw los ntawm ob-nqe lus"

Cov syntax no tshwm sim thaum peb siv cov hlua. Qhov teeb meem tau ua nrog qhib tab sis tsis kaw txoj hlua. Nws yog ib txwm cim rau ntawm kab uas nws tshwm sim thiab tau tsau los ntawm kev tso cov lus hais thib ob. Raws li cov lus ceeb toom, yog tias koj sim siv ib qho kev hais tawm rau Strings uas tseem yuav ua rau muaj qhov yuam kev "tus cwj pwm tsis raug".

Kauj Ruam 8: "Rov Hom Rau Txoj Kev Tsis Muaj"

"Rov Hom rau Txoj Kev Tsis Muaj"
"Rov Hom rau Txoj Kev Tsis Muaj"
"Hom rov rau Txoj Kev Yog Tsis Muaj"
"Hom rov rau Txoj Kev Yog Tsis Muaj"

Lub Syntax kawg tsim nyog hais txog yog hom rov qab thiab ploj lawm rov qab. Qhov "xa rov qab rau txoj hauv kev yog ploj lawm" tshwm sim thaum koj muaj txoj hauv kev sim rov qab qee yam thaum tsis muaj qhov tshwj xeeb ntawm hom ntawd hauv cov txheej txheem kos npe. Qhov yuam kev yuav tshwm sim hauv qhov kos npe thiab feem ntau yog kev daws teeb meem sai heev. Thaum nws los txog rau "txoj hauv kev yuav tsum rov qab los ntawm hom" yuam kev koj tsuas yog xav tau kom ntseeg tau tias koj rov qab qee yam nrog hom ntawd.

Kauj Ruam 9: Kev Pab Ntxiv

Yog tias koj tsis tuaj yeem nrhiav qhov kho rau koj qhov ua yuam kev, tom qab ntawd txiav txim siab sim ib qho ntawm cov hauv qab no kev xaiv. Luam Java cov ntawv sau tseg ntawm qhov ua yuam kev uas tshwm sim thiab sim nrhiav kev daws teeb meem los ntawm muab nws tso rau hauv qee qhov kev tshawb fawb hauv web. Tshawb nrhiav qee qhov qib siab dua lossis qhia meej Java yuam kev tuav cov lus qhia. Thaum kawg, yog tias tsis muaj ib qho ntawm cov kev xaiv no tau pab thiab koj muaj sijhawm txaus, sim tshaj tawm koj cov lus nug ntawm kev sib tham txhawb nqa xws li Stackoverflow. Koj yuav nquag tau txais cov lus teb kho nrog piav qhia vim li cas qhov ua yuam kev tshwm sim thawj zaug.

Pom zoo: