comparison operators in Java
The comparison operator is used to determine the size of two data, for example: greater than, equal to, not equal to. The result of the comparison is a Boolean value (True or false).
The common comparison operators in Java are shown in the following table:
650) this.width=650; "src=" http://img.mukewang.com/536063f00001b7b904350145.jpg "/>
Attention, OH:
1, >, <, >=, <= only support the left and right sides of the operand is a numeric type
2, = =,! = The operands on either side of the number can be numeric types, or they can be reference types
Code:
public class helloworld{
public static void Main (string[] args) {
int a=16;
Double b=9.5;
String str1= "Hello";
String str2= "IMOOC";
System.out.println ("A equals B:" + (a== b));
SYSTEM.OUT.PRINTLN ("A greater than B:" + (a> b));
System.out.println ("A is less than or equal to B:" + (A < b));
System.out.println ("str1 equals str2:" + (str1 = str2));
}
}
Operation Result:
A equals B:false.
A greater than b:true
A is less than or equal to B:false
Str1 equals Str2:imooc.
This article is from "Ghost" blog, please make sure to keep this source http://caizi.blog.51cto.com/5234706/1547669
Java Basics---Comparison operators in Java (13)