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

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -