Java true and false

true and false

The boolean data type is boolean.

Main.java


class Main {
  public static void main(String[] args) {
    int number = 5;
  }
  if (isEven(number)) {
    System.out.println(number + "Even");
  } else {
    System.out.println(number + "Odd");
  public static boolean isEven(int a) {
    return a % 2 == 0;
  }
}

In the above, the isEven method checks if the argument value is even and returns true if it is even and false if it is odd.

Recommended Posts

Java true and false
Java and JavaScript
XXE and Java
Getters and setters (Java)
[Java] Thread and Runnable
[Java] String comparison and && and ||
Java --Serialization and Deserialization
[Java] Arguments and parameters
timedatectl and Java TimeZone
[Java] Branch and repeat
[Java] Variables and types
java (classes and instances)
[Java] Overload and override
Java version 8 and later features
[Java] Stack area and static area
[Java] Generics classes and generics methods
Java programming (variables and data)
Java encryption and decryption PDF
Java and Iterator Part 1 External Iterator
Java if and switch statements
Java class definition and instantiation
Apache Hadoop and Java 9 (Part 1)
[Java] About String and StringBuilder
[Java] HashCode and equals overrides
☾ Java / Iterative statement and iterative control statement
Java methods and method overloads
java Generics T and? Difference
Advantages and disadvantages of Java
java (conditional branching and repetition)
About Java Packages and imports
[Java] Upload images and base64
C # and Java Overrides Story
Java abstract methods and classes
Java while and for statements
Java encapsulation and getters and setters
About Java static and non-static methods
I compared PHP and Java constructors
Differences between "beginner" Java and Kotlin
Use java with MSYS and Cygwin
Distributed tracing with OpenCensus and Java
[Java] Difference between Hashmap and HashTable
Java variable declaration, initialization, and types
Java Excel Insertion and Image Extraction
Install Java and Tomcat with Ansible
AWS SDK for Java 1.11.x and 2.x
[Java] Basic types and instruction notes
Java release date and EOL summary
Java and first-class functions-beyond functional interfaces-
About fastqc of Biocontainers and Java
Java for beginners, expressions and operators 1
[Java beginner] About abstraction and interface
Basic data types and reference types (Java)
[Java] Loop processing and multiplication table
Java 15 implementation and VS Code preferences
Java arguments, return values and overloads
OpenJDK 8 java and javac command help
Java reference mechanism (stack and heap)
Use JDBC with Java and Scala.
Java for beginners, expressions and operators 2
Java PowerPoint password setting and cancellation
Java 9 new features and sample code