This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String audioSystemVersion = "UNKNOWN"; | |
if (myCar != null) { | |
AudioSystem audioSystem = myCar.getAudioSystem(); | |
if (audioSystem != null) { // the card has audio system. | |
audioSystemVersion = audioSystem.getVersion(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Optional<AudioSystem> sc = Optional.empty(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AudioSystem audioSystem = new AudioSystem(); | |
Optional<AudioSystem> as = Optional.of(audioSystem); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Optional<AudioSystem> as = Optional.ofNullable(audioSystem); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AudioSystem as = ....; | |
if (as != null) { | |
Sysmte.out.println(as); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Optional<AudioSystem> as = ...; | |
as.ifPresent(System.out::println); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Optional<AudioSystem> audioSystem = ...; | |
if(audioSystem.isPresent()){ | |
System.out.println(audioSystem.get()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AudioSystem as = ...; | |
if(as != null && "Pionner".equals(as.getBrand())){ | |
System.out.println(as); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Optional<AudioSystem> maybeAudioSystem = ...; | |
maybeAudioSystem.filter(as -> "Pionner".equals(as.getBrand()) | |
.ifPresent(as -> System.out.println(as)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(car != null){ | |
AudioSystem as = car.getAudioSystem(); | |
if(as != null && "Pionner".equals(as.getBrand()){ | |
System.out.println("ok"); | |
} | |
} |
OlderNewer