mardi 26 septembre 2017

Assigning variable based on condition in Java

In one of my Python scripts I have the following line:

opener = "open" if sys.platform == "darwin" else "xdg-open"

Is it possible to do this as a one-liner in Java? I tried

int x = if(true) { 7 } else { 4 };

but I've come up with nothin.

Aucun commentaire:

Enregistrer un commentaire