Java Basics---Comparison operators in Java (13)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.