本文共 1717 字,大约阅读时间需要 5 分钟。
java isset
isSet() method is available in java.util package.
isSet()方法在java.util包中可用。
isSet() method is used to test whether the given field of this calendar is set or not it returns true when the given parameter (fi) has been set by internal field interpretations.
isSet()方法用于测试是否已设置此日历的给定字段,当内部字段解释已设置给定参数(fi)时,它返回true。
isSet() 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.
isSet()方法是一种非静态方法,可通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
isSet() method does not throw an exception at the time of checking the given field is set.
在检查给定字段设置时, isSet()方法不会引发异常。
Syntax:
句法:
public final boolean isSet(int fi);
Parameter(s):
参数:
int fi – represents the calendar field(fi) to be tested.
int fi –代表要测试的日历字段(fi)。
Return value:
返回值:
The return type of the method is boolean, it returns true when the given calendar field is set otherwise it returns false.
方法的返回类型为boolean ,当设置给定日历字段时返回true,否则返回false。
Example:
例:
// Java Program to demonstrate the example of// boolean isSet(int fi) method of Calendarimport java.util.*;public class IsSet { public static void main(String args[]) { // Instantiating a Calendar object Calendar ca = Calendar.getInstance(); System.out.println("ca =" + ca.getTime()); // By using isSet(int fi) method is to // check the given field is set or // not of this Calendar boolean status = ca.isSet(Calendar.MONTH); //Display status System.out.println("ca.isSet(Calendar.MONTH): " + status); }}
Output
输出量
ca =Mon Jan 27 08:38:21 GMT 2020ca.isSet(Calendar.MONTH): true
翻译自:
java isset
转载地址:http://vwozd.baihongyu.com/