First day of Java

Source: Internet
Author: User
Tags float double float number

(a) Introduction to Java
1.java first Sun, then Oracle, Java was originally designed to meet the memory, computing speed of a limited number of devices running
Java is divided into: Java EE javase for each platform
2. Installing the JDK
Unzip the downloaded JDK to the current folder.
Computer--Properties--Advanced system settings-environment variables--System variables
Create a new Java_home variable in the system variable with the contents of the current JDK directory
Create a new classpath variable with the contents of the current directory (. means the current directory)
To modify the path variable, add the directory path to the JDK home directory before the contents of the variable
3. Complete the Java project with Notepad
Write the source code: In Notepad, note that the suffix is changed to. class
Compiling source code: Javac+java The name of the source file (including suffix) in command mode
Run Source: Java+java The name of the class in the source file (not including the suffix)


(ii) data type
1. Basic type
integer; int long short
4 8 2 byte
Float type: float double (float default) float number=12. 1 is the wrong float number =12.1f default double number=12.1
                  4   &N Bsp                              8-byte
Boolean: Boolea n due to only true and false two results, only 1-bit
character type: Byte              char
      &NBS P      1 (ASCII) 4-byte (Unicode)

2. Reference type (all data types except the base type)
(iii) data type conversion
Cast (also known as display transformation, the target type of the conversion must be written out when converting): big-to-small high-low
Auto-convert (also called implicit)
Note When you are in equal space (a float type is cast to an int type). But int is converted to float for automatic conversion, but it is added to the int type value. 0)
float first=12.1;
int Second=first is wrong, int type has no way to store decimal value can only int second= (int) First
But
int first=12;
Float Second=first is possible, only the result is 12.0
The same is also double and long, and the Boolean type cannot be converted with other base types
(iv) operator
Assignment value:
= += -= *= /= %= ++ --
Arithmetic:
+ - * /
Comparison:
> < >= <= = = =!
Logic:
&& | | !
(v) Variables
Variables must be initialized before use, you can define the re-assignment, you can also assign values at the same time as defined

First day of Java

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.