Java Learning Notes---Use of some keywords

Source: Internet
Author: User

First, instanceofFunction: Determines whether a variable of a reference type points to an instance of an object (or interface, abstract class, parent class).Usage: Boolean result= object instanceof class. Second, STRICTFPFunction: Used to ensure the accuracy of floating-point arithmetic. If you do not specify the STRICTFP keyword, the calculation results may be inaccurate at this time. This keyword guarantees that the Java compiler and the operating environment are executed exactly in accordance with the IEEE binary floating-point arithmetic standard.Usage:
Public strictfp class Test{public static void Teststrictfp () {float f=0.12356f;double d=0.03496421d;double sum =d+f; SYSTEM.OUT.PRINTLN (sum);} public static void Main (String args[]) {TESTSTRICTFP ();}}


Operation Result: 0.15861420949932098. AssertFunction: As a method of software debugging, it provides a few of the correctness check in code. The main thing is to check a Boolean expression, a properly running program must ensure that the value of the Boolean expression is true, if the expression value is False, then the program is in an incorrect state, the system needs to provide warning information and launch.Usage: Two expressions: Assert expression1 and Assert expression1:expression2public class test{public static void Main (String args[]) {Assert 1+1==2;System.out.println ("Assert1 OK");assert 1+1==3: "Assert2 faild, Exit";System.out.println ("assert OK");}} For the above code, when executing the instruction Javac Test.java and Java Test, the program outputs the result:Assert1 OKAssert2 OK
When the Javac Test.java and Java-ea Test programs are executed, the output results are:Assert1 OKException in thread "main" Java lang. Assertionerror:assert faild,exit ...

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Java Learning Notes---Use of some keywords

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.