optimisation du code list-java
PHP中文网
PHP中文网 2017-05-17 10:08:39
0
2
558

La version actuelle peut fonctionner, mais l'écriture n'est certainement pas bonne.

List data = weatherReportDao.getCoviReportData(reportType); WeatherENUM weatherENUM = WeatherENUM.valueOf(reportFunction); switch (weatherENUM){ case atmosphere: data = atmosphereReportDao.getAtmosphereReportData(reportType); break; case covi: data = weatherReportDao.getCoviReportData(reportType); break; case windSpeed: data = windSpeedReportDao.getWindSpeedReportData(reportType); break; } return data;

La clé est l'initialisation des données. Si elles ne sont pas initialisées, une erreur sera signalée. Demandez conseil.

PHP中文网
PHP中文网

认证高级PHP讲师

répondre à tous (2)
習慣沉默
List data = null;

Ou trouver un moyen de passer une certaine valeur de WeatherENUM en paramètre à dao

List data = weatherReportDao.getReportData(reportType,dataType);
    phpcn_u1582

    Si elle est définie comme variable globale, il n'est pas nécessaire de l'initialiser.

      Derniers téléchargements
      Plus>
      effets Web
      Code source du site Web
      Matériel du site Web
      Modèle frontal
      À propos de nous Clause de non-responsabilité Sitemap
      Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!