Java language Basics

Source: Internet
Author: User
Tags float double

1.java annotations

Single-line comment//

Multiline Comment/* */

Javadoc Comment/** */

(1.javadoc annotations can only be played on classes and methods

2.javadoc can extract annotations to generate HTML files

3. Command format javadoc-d Doc Helloworld.java) (not yet complete operation??? )

2. Package

Better positioning classes, placing classes of the same function in a package

Note: The classes in the Java.lang package do not use import directly

Java package naming requirements do not start with Java, it is recommended to use the company's domain name to write the Java class package

3.jar (Dozen jar packs)

Jar packaging jar CVF Jiami.jar Helloworld.class

4. Identifiers

Currency symbol, letter, number, underline

(Cannot use Java keyword, cannot start with a number)

The Java language reserved but not used keyword goto const

Naming habits

Package name: All lowercase COM.ORACLESDP

Class Name/interface: Capitalize the first letter of each word helloworld/hellointerface

Variable/method Name: First letter lowercase each word capitalized studentname/showname

Constants: Capitalize each word, underline connections between multiple words request_code

5. Eight large base type integer type (byte short int long) floating-point type (float double) character type (char) Boolean type (Boolean)

Corresponding package type Byte short Integer Long Float Double Character Boolean

Object data Type (string)

int I=integer.parseint (str); SYSTEM.OUT.PRINTLN (Integer.parseint (str) +1);//String to basic type

Double d = 2.0-1.1;    System.out.println (d);//0.8999999999999999

Floating point loss accuracy problem

Double a=2.0;    Double b=1.1;    System.out.println (Bigdecimal.valueof (a). Subtract (bigdecimal.valueof (b)). Doublevalue ());} 0.9    

(There are altogether 4 construction methods of BigDecimal:

BigDecimal (int) Creates an object with the integer value specified by the parameter. BigDecimal (double) creates an object with the double value specified by the parameter. BigDecimal (long) creates an object with a long integer value specified by the parameter. BigDecimal (String) creates an object that has the numeric value specified by the parameter as a string. BigDecimal operation does not support +-*/This type of operation it has its own method of Operation BigDecimal Add (bigdecimalaugend) addition Operation BigDecimal Subtract (BigDecimal subtrahend Subtraction Operation BigDecimal Multiply (BigDecimal multiplicand) multiplication Operation BigDecimal Divide (BigDecimal divisor) division operation)

Java language Basics

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.