public class Playground {
public static void main(String[] args) {
String s = "blah";
Character lclfs = s.contains("/") ? '/' : s.contains("\\") ? '\\' : null;
}
}
What am I missing (using Java 1.8)?
public class Playground {
public static void main(String[] args) {
String s = "blah";
Character lclfs = s.contains("/") ? '/' : s.contains("\\") ? '\\' : null;
}
}
What am I missing (using Java 1.8)?

That is because your code will try to unbox
null. Using IntelliJ this will be shown directly as warning: "Unboxing of null may produce NullPointerException".An alternative would be to do it like this:
As @Antoniossss pointed out, this would also help:
Talking about warnings in IntelliJ, my above code is now saying: ”Unnecessary boxing 'Character.valueOf('\')'”. So probably you should try to refactor your code. Instead of using explicit
null, you could introducejava.util.Optional: