Ternary operators can’t have statements that don’t return values, void
methods. You need statements that have return values.
You need to rewrite it.
void bark(boolean hamlet) {
System.out.println( hamlet ? "To Bark." : "Not to Bark" );
}
More Related Contents:
- Write 1 line If statement using ternary operator in JAVa
- What is the Java ?: operator called and what does it do?
- What is a Question Mark “?” and Colon “:” Operator Used for? [duplicate]
- Ternary Operator – JAVA [duplicate]
- Ternary Operators Java
- Why does the ternary operator unexpectedly cast integers?
- Java Ternary without Assignment
- Unexpected type resulting from the ternary operator
- “Wrong” return type when using if vs. ternary opertator in Java
- Why ternary operation gives nullpointer while its ifelse counterpart doesn’t? [duplicate]
- ternary operator not working
- Need assistance with having executable code
- printing multiple results using, System.out.println
- Should I avoid the use of set(Preferred|Maximum|Minimum)Size methods in Java Swing?
- How to make a JTable non-editable
- Migration from Struts 1 to Struts 2
- How to set request encoding in Tomcat?
- Why does int num = Integer.getInteger(“123”) throw NullPointerException?
- Android heterogeneous gridview like pinterest? [closed]
- Java TreeMap Comparator
- @Valid annotation is not validating the list of child objects
- Which JDK version (Language Level) is required for Android Studio?
- How do you double buffer in java for a game?
- Why are interface method invocations slower than concrete invocations?
- Spring Boot – Environment @Autowired throws NullPointerException
- Can non-static methods modify static variables
- creating final variables inside a loop
- How can I open Java .class files in a human-readable way?
- How does clone work under the hood?
- Using Gson with Interface Types