java - Ternary operator is not a statement -
i've following ternary expression:
((!f.exists()) ? (f.createnewfile() ? printfile() : throw new exception("error in creating file")) : printfile());
for one, or more, reason don't know idea ide me isn't statement. why?
this not valid, need return value
printfile() : throw new exception("error in creating file")
try one
if(f.exists() || f.createnewfile()) { printfile(); }else{ throw new exception("error in creating file"); }
Comments
Post a Comment