Assign evaluation result to Java variable

The code to assign the evaluation result to the variable was difficult to understand, so I summarized it to keep my head in order.

Substitute the evaluation result into a variable

python


 int number = 1;
 boolean flag = number == 1;
        
 System.out.println(flag);

The processing result displayed at this time is スクリーンショット 2020-08-12 16.40.35.png become. The display result with "0" in number is "false", but it was difficult to understand, so I supplemented it for myself.

Decompose boolean flag = number == 1;

python


/*If number is "1", flag is "ture"*/
if(number == 1){
  boolean flag = true;
}
/*If number is "0", flag is "false"*/
else
{
  boolean flag = false;
}

Recommended Posts

Assign evaluation result to Java variable
Assign a Java8 lambda expression to a variable and reuse it
How to write Java variable declaration
[Introduction to Java] Variable declarations and types
java array variable
Java variable scope (scope)
java variable declaration
Java variable scope
[Java] Introduction to Java
Introduction to java
Changes from Java 8 to Java 11
Sum from Java_1 to 100
[Java] Connect to MySQL
Regarding Java variable usage
Kotlin's improvements to Java
From Java to Ruby !!
[Introduction to Java] Variable scope (scope, local variables, instance variables, static variables)
Introduction to java command
Be sure to compare the result of Java compareTo with 0
[Java] How to use Map
How to lower java version
Migration from Cobol to JAVA
[Java] How to use Map
Convert Java Powerpoint to XPS
Java adds table to PDF
Dynamically assign Controller to JavaFX-fxml
How to uninstall Java 8 (Mac)
Java to play with Function
Java --How to make JTable
How to use java Optional
New features from Java7 to Java8
How to minimize Java images
About Java variable declaration statements
How to write java comments
[Java] How to use Optional ②
Connect from Java to PostgreSQL
[Java] How to use removeAll ()
Pass a variable to Scope.
[Java] Introduction to lambda expressions
[Java] How to use string.format
Shell to kill Java process
How to use Java Map
Connect to DB with Java
Connect to MySQL 8 with Java
How to use Java variables
[Java] Introduction to Stream API
Java8 to start now ~ Optional ~
How to convert Java radix
[Java] Convert ArrayList to array
Java thread to understand loosely
[Java] How to implement multithreading
[Java] How to use Optional ①
From Ineffective Java to Effective Java
How to initialize Java array
[Introduction to rock-paper-scissors games] Java
Input to the Java console