Cov txheej txheem:

Kuv yuav ua li cas tshem tawm tag nrho cov lus ceeb toom hauv Java?
Kuv yuav ua li cas tshem tawm tag nrho cov lus ceeb toom hauv Java?

Video: Kuv yuav ua li cas tshem tawm tag nrho cov lus ceeb toom hauv Java?

Video: Kuv yuav ua li cas tshem tawm tag nrho cov lus ceeb toom hauv Java?
Video: Yuav ua li cas thiaj khiav dim lub ntiajteb no 2024, Plaub Hlis Ntuj
Anonim

Tej zaum koj tsuas yog siv @SuppressWarnings("tsis tau txheeb xyuas") txhawm rau txhawm rau txwv tsis pub cov lus ceeb toom hauv Java

  1. Hauv chav kawm. Yog siv rau qib kawm, tag nrho cov txheej txheem thiab cov tswv cuab hauv chav kawm no yuav tsis quav ntsej qhov tsis tau txheeb xyuas ceeb toom lus.
  2. Hauv Txoj Kev. Yog tias siv rau theem txheej txheem, tsuas yog txoj kev no yuav tsis quav ntsej qhov tsis tau txheeb xyuas ceeb toom lus.
  3. Hauv Tsev.

Yog li ntawd, vim li cas peb thiaj li siv cov lus ceeb toom txwv?

Lub SuppressWarning annotation yog siv rau txwv compiler ceeb toom rau lub ntsiab lus piav qhia. Tshwj xeeb, cov qeb tsis tau txheeb xyuas tso cai kev quab yuam ntawm compiler ceeb toom generated los ntawm unchecked hom casts. Yooj yim: Nws yog a ceeb toom los ntawm qhov uas lub compiler qhia tias nws tsis tuaj yeem ua kom muaj kev nyab xeeb ntawm hom.

Tom qab ntawd, lo lus nug yog, @SuppressWarnings deprecation yog dab tsi? Cov @ SuppressWarnings annotation disables tej lus ceeb toom compiler. Hauv qhov no, ceeb toom txog cov cai tsis raug cai (" kev txiav txim siab ") thiab cov kev hloov pauv hauv zos tsis siv lossis tsis siv cov txheej txheem ntiag tug ("tsis siv").

Hauv qhov no, @SuppressWarnings Rawtypes yog dab tsi?

@ SuppressWarnings qhia lub compiler kom tsis quav ntsej lossis txwv tsis pub, teev cov lus ceeb toom ntawm cov lus ceeb toom hauv cov lus piav qhia thiab txhua qhov kev pab cuam hauv lub ntsiab lus ntawd. Piv txwv li, yog hais tias ib chav kawm yog annotated los suppress ib qho kev ceeb toom, ces ib tug ceeb toom generated nyob rau hauv ib txoj kev nyob rau hauv cov chav kawm ntawv kuj yuav raug muab cais.

Dab tsi yog qhov kev ceeb toom deprecation hauv Java?

" Kev txiav txim siab ", ceeb toom tsa, los ntawm Java compiler, yog ntau heev rau a Java programmer. Nws raug tsa thaum tus programmer siv ib txoj kev uas pom muaj faulty lossis teeb meem. Cov tsis pom zoo txoj kev tuaj yeem raug tshem tawm ntawm JDK yav tom ntej versions.

Pom zoo: