java的equals方法_Java Date equals()方法与示例

java的equals方法

日期类equals()方法 (Date Class equals() method)

  • equals() method is available in java.util package.

    equals()方法在java.util包中可用。

  • equals() method is used to check whether this date and the given object (o) are equals or not.

    equals()方法用于检查此日期和给定对象(o)是否相等。

  • equals() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    equals()方法是一种非静态方法,仅可通过类对象访问,如果尝试使用类名访问该方法,则会收到错误消息。

  • equals() method does not throw an exception at the time checking equality of this date object with the given object (o).

    在检查此日期对象与给定对象(o)的相等性时, equals()方法不会引发异常。

Syntax:

句法:

    public boolean equals(Object o);

Parameter(s):

参数:

  • Object o – represents the object to be compared with this date.

    对象o –表示要与此日期进行比较的对象。

Return value:

返回值:

The return type of this method is boolean, it returns true when two date objects are equals otherwise it returns false.

此方法的返回类型为boolean ,当两个日期对象相等时返回true,否则返回false。

Example:

例:

// Java program to demonstrate the example 
// of boolean equals(Object o) method of Date
import java.util.*;
public class EqualsOfDate {
public static void main(String[] args) {
// create two Date object with two dates
Date this_date = new Date(2016, 8, 20);
Date given_date = new Date(2010, 11, 30);
// By using equals() method is to check 
// equality of this_date and the given_date
boolean status = this_date.equals(given_date);
// Display status
System.out.println("this_date.equals(given_date): " + status);
}
}

Output

输出量

this_date.equals(given_date): false

翻译自: https://www.includehelp.com/java/date-equals-method-with-example.aspx

java的equals方法

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/540972.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

lnmp解析php,LNMP之 php解析

[rootLNMP ~]# vim /usr/local/nginx/conf/nginx.conf打开以下PHP 相关项且更改 scripts$fastcgi_script_name;> /usrlocal/nginx/html$fastcgi_script_name;location ~ \.php$ {root html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param…

spring历史背景

1.2004年spring出现第一版本spring frameworl1.0 2.写代码永远是最简单的,后续的运维工作才是让人感到无助的 3.spring boot在运维方面做了很多工作,部署,监控,度量。结合spring cloud还可以实现服务发现,服务降级等功…

计算机网络中的传输协议是_计算机网络中的传输方式

计算机网络中的传输协议是传输方式 (Transmission Modes) The mechanism of transferring data or information between two linked devices connected over a network is referred to as Transmission Modes. 在通过网络连接的两个链接的设备之间传输数据或信息的机制称为传输…

https 密钥 php,https加密方式是什么

Https加密介绍Http直接通过明文在浏览器和服务器之间传递消息,容易被监听抓取到通信内容。Https采用对称加密和非对称加密结合的方式来进行通信。Https不是应用层的新协议,而是Http通信接口用SSL和TLS来加强加密和认证机制。加密方式对称加密&#xff1a…

一个前端框架应该有的一些公共函数

一、防止ie浏览器按backspace回退页面 //防止后退返回页面,如果非文本框、密码框、文本域控件,或控件非可用装填,则禁用后退按键 var uanavigator.userAgent.toLowerCase(); var isIEua.indexOf("msie")>-1; window.document.onkeydown fu…

Kruskal(P)和Prim(K)算法

最小生成树 (Minimum Spanning Tree) An MST is a subset of the edges of the connected, undirected graph that connect all the vertices together, in which there is no forming of a cycle and there should be minimum possible total edge weight. MST是已连接的无向图…

java get post 注解,GET/POST接收或发送数据的问题

在文章开始,先来回忆一下GET、POST这两种请求方式的区别。❈Http定义了与服务器交互的不同方法,最基本的方法有4种,分别是GET,POST,PUT,DELETE。URL全称是资源描述符,我们可以这样认为&#xff…

mybatis中sql语句传入多个参数方法

1 使用map <select id"selectRole" parameterType"map" resultType"RoleMap">SELECT id, roleName, noteFROM roleWHERE roleName LIKE Concat(%,#{roleName},%)and note like Concat(%,#{note},%)</select> 在接口中如下定义 List&…

kotlin半生对象_Kotlin程序| 随播对象特征

kotlin半生对象伴侣对象 (Companion object) If you need a function or a property to be tied to a class rather than to instances of it (similar to static in java), you can declare it inside a companion object: 如果需要将函数或属性绑定到类而不是实例(类似于java…

mysql安装注意步骤,mysql安装步骤

mysql安装步骤1、在官网下载对应的压缩文件&#xff0c;放到本地文件夹下&#xff0c;解压缩。2、配置Path环境变量&#xff1a;新增mysql的bin文件夹路径&#xff0c;C:\software\mysql-8.0.23-winx64\bin。3、在mysql根目录下新增my.ini配置文件。内容如下&#xff0c;basedi…

maven插件介绍之tomcat7-maven-plugin

tomcat7-maven-plugin插件的pom.xml依赖为&#xff1a; <dependency><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><version>2.2</version> </dependency>一&#xff1a;直接执行…

在Python中模拟do-while循环

Python as a language doesnt support the do-while loop. However, we can have a workaround to emulate the do-while loop. Python作为一种语言不支持do-while循环。 但是&#xff0c;我们可以采用一种变通方法来模拟do-while循环 。 The syntax for do-while is as follo…

织梦cms生成首页html的php文件,织梦DedeCMS定时自动生成首页HTML的实现方法

只需要制作一个文件然后在首页模板添加一句代码就可以实现让织梦DedeCMS自动生成首页html&#xff0c;具体方法如下&#xff1a;第一步、需要在首页调用随机文章&#xff0c;这样每次自动更新才会有更新的效果&#xff0c;随机文章调用标签如下&#xff1a;{dede:arclist sortr…

Linux下安装Flume

1 下载Flume Welcome to Apache Flume — Apache Flume 下载1.9.0版本 2 上传服务器并解压安装 3 删除lib目录下的guava-11.0.2.jar &#xff08;如同服务器安装了hadoop&#xff0c;则删除&#xff0c;如没有安装hadoop则保留这个文件&#xff0c;否则无法启动flume&#…

Apple新发布的APFS文件系统对用户意味着什么

2016年WWDC大会上&#xff0c;Apple除了公布watchOS、tvOS、macOS以及iOS等一系列系统和软件更新外&#xff0c;还公布了一个名为APFS&#xff08;Apple File System&#xff09;的文件系统。 这一全新文件系统专门针对闪存/SSD进行优化&#xff08;但依然可用于传统机械硬盘&a…

chown –r mysql:mysql,mysql部署,操作及异常处理

1、将mysql-5.1.50-linux-x86_64-glibc23.tar.gz移至/usr/local/目录下&#xff0c;并改名为mysql增加mysql组#groupadd mysql建mysql用户&#xff0c;并加入到mysql组中#useradd –g mysql mysql源码包解压#tar mysql-5.1.50-linux-x86_64-glibc23.tar.gz将解压后的源码包放置…

光伏等新能源信用风险事件频繁爆发

2016年以来&#xff0c;伴随着供给侧改革相关政策陆续出台和落地&#xff0c;去产能、去杠杆诱发信用风险事件陆续爆出。而在“11天威NTN1”、“15云峰PPN001”及“15云峰PPN003”等信用风险事件上&#xff0c;大股东“弃车保帅”行为再现&#xff0c;令本就失去造血能力的企业…

ruby array_Ruby中带有示例的Array.zip()方法

ruby arrayArray.zip()方法 (Array.zip() Method) In this article, we will study about Array.zip() Method. You all must be thinking the method must be doing something which is related to zipping values of the Array instance. It is not as simple as it looks. W…

matlab中迪杰斯特拉算法,dijkstra算法(迪杰斯特拉算法)

单源最短路径算法——Dijkstra算法&lpar;迪杰斯特拉算法&rpar;一 综述 Dijkstra算法(迪杰斯特拉算法)主要是用于求解有向图中单源最短路径问题.其本质是基于贪心策略的(具体见下文).其基本原理如下: (1)初始化:集合vertex_set初始为{sourc ...Dijkstra【迪杰斯特拉算法…

关于概率算法的问题,不知道逻辑错在哪里,求debug

做个骰子成功几率的分析&#xff0c;投n颗骰子&#xff0c;第一次投成功的几率是a,然后投成功的骰子&#xff0c;需要再投1次&#xff0c;这次成功的几率是b。第二次成功的骰子才算最终成功。 要分析出n颗骰子&#xff0c;最终成功0到n颗的概率。 我写了个算法&#xff0c;求出…