博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java clone方法_Java Calendar clone()方法与示例
阅读量:2529 次
发布时间:2019-05-11

本文共 1563 字,大约阅读时间需要 5 分钟。

java clone方法

日历类clone()方法 (Calendar Class clone() method)

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

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

  • clone() method is used to return the cloned object of this Calendar object.

    clone()方法用于返回此Calendar对象的克隆对象。

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

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

  • clone() method does not throw an exception at the time of cloning Calendar object.

    在克隆Calendar对象时, clone()方法不会引发异常。

Syntax:

句法:

public Object clone();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

In both the cases, the return type of the method is Object, it returns a copy to this object.

在这两种情况下,方法的返回类型均为Object ,它将返回此对象的副本。

Example:

例:

// Java Program to demonstrate the example of// Object clone() method of Calendarimport java.util.*;public class CloneOfCalendar {
public static void main(String[] args) {
// Instantiating two Calendar object Calendar curr_ca = Calendar.getInstance(); Calendar clo_ca; // Display current calendar System.out.println("curr_ca: " + curr_ca.getTime()); // By using clone() method is to copy the // object to another clo_ca = (Calendar) curr_ca.clone(); // Display cloned calendar System.out.println("curr_ca.clone(): " + clo_ca.getTime()); }}

Output

输出量

curr_ca: Thu Jan 23 11:42:29 GMT 2020curr_ca.clone(): Thu Jan 23 11:42:29 GMT 2020

翻译自:

java clone方法

转载地址:http://khxzd.baihongyu.com/

你可能感兴趣的文章
JQuery 事件
查看>>
main(argc,argv[])
查看>>
源码:Java集合源码之:哈希表(二)
查看>>
【HDU 3709】 Balanced Number (数位DP)
查看>>
JsonPath的使用
查看>>
企业常用的站内收索、QQ群、在线客服
查看>>
Centos下安装nginx步骤解析
查看>>
EntityFramework Code First 添加唯一键
查看>>
在线教育工具—白板系统的迭代1——bug监控排查
查看>>
招行ODC项目表彰
查看>>
js补充知识点-label应用
查看>>
给构造函数(constructor)创建对象(object)
查看>>
局域网访问PHP项目网站 用IP地址进入
查看>>
VM虚拟机,Linux系统安装tools过程遇到 what is the location of the “ifconfig” program
查看>>
Jquery实现循环删除Reaper某一行
查看>>
脚本升级openssh
查看>>
linux学习(3)——vim文本编辑工具
查看>>
快速开发平台如何应用
查看>>
hadoop的理解
查看>>
Java测试当前应用所占用的内存示例
查看>>