Search code examples
javagwtgxt

What does this represent in java?


      servicesDto.setPhotospath(values.get("photospath") == null ? null
              :values.get("photospath").toString());

What is represented here and why is null used in this manner: '== null ? null'

Note : I am Fresher please give me a such reference and Explain me Bro/Sis/Friends.

Thanking you...!!!


Solution

  • This is called short form (ternary) if else your code above is equivalent to the following:

    if(values.get("photospath") == null){
           servicesDto.setPhotospath(null);
    }else{
           servicesDto.setPhotospath(  values.get("photospath").toString())  );
    }