Thousand Peaks training Day01-java Basic Learning: history, data type

Source: Internet
Author: User

Class notes:
Today's content:

Version development of Java:
Java is a high-level language for Sun development, 1995
March 2014 The latest version is 8.0

Branches of Java:
1. Javase: Standard Edition, Java Starter and desktop application development
2, Java EE: Enterprise Edition, mainly web development
3, Javame: Miniature version, mainly digital top box, car system

Features of Java:
1. Cross-platform
2. Object-oriented
3. Garbage collection
4. Robust language

The two main core of Java:
1, Jvm:java virtual machine, the reason for the implementation of cross-platform, is because of the various operating systems provided by the JVM
2, GC: Garbage collection mechanism, programmers can not interfere

Java Program Development steps:
1. Programmers write Java source files
2. Execute the javac command to compile the source file into a bytecode file
3. Execute Java command, run program


Development steps:
1. Right-click to create a new document, the contents of the document:
public class file name
{
public static void Main (string[] args)
{
Output statements, etc.
}
}
2, rename the above file, the file suffix name is. java
3. Open run, enter CMD, enter the directory where the source files are located
4. "Javac file name. Java" compiles the source file, resulting in "file name. Class"
5. "Java File name" execution program

The format of the main function:
public static void Main (string[] args)
{

}


Development essentials:
A Java source file has at most one public-decorated class
A source file may produce multiple bytecode files (. Class)
The symbols appearing in the program are in English.

Comments in Java:
1, single-line comment://comment Content
2. Multi-line Comment:/* Multiline Comment */
3. Document Comment:/** document Comment */

Development Note:
1, a source file can only have one public class or interface declaration, the number of other classes are unlimited.
2. The source file name must be the same as the class name of the public defined in it
3. Java language word spelling is strictly case-sensitive
4. The main method is the entry method for Java applications
5, the program body can only use English punctuation,;:() []{}<>? etc

Identifier: A sequence of characters, such as a class name, method name, parameter name, variable name, object name, is called an identifier.
Naming rules:
1, composed of letters, numbers, underline _, dollar sign $
2. Cannot start with a number,
3, case-sensitive, unlimited length,
4. Cannot be reserved words and keywords in Java
Example: _abc,-num, 12d, bas$, I _
Naming habits:
1, the general length of not more than 15 characters
2, see the name of the idea
3, Hump-type naming
Class Name: The first letter of a word capitalized: Sudentinfo
Method name, variable name, and so on: first letter in lowercase: getInfo


B--1024-->kb--1024-->m--1024-->g--1024-->t

Data types in Java:
I. Basic data types
Numeric type
1, Integer type
1, Byte (bytes)--8 bits (one byte = 8 bits)
2, short (shorter integer)--2 bytes
3, int (integral type)--4 bytes 32 bits
4, long (length integer)--8 Bytes: The number must be appended with L/L
2, floating-point type
1, float (single precision)-4 bytes: Number must be added after the f/f, if not the default with a decimal number is a double type.
2, double (doubles)--8 bytes
3, Character type
1, char (character)--2 bytes, description range: [0,65535]
4. Boolean type:
1, Boolean (Boolean): Value: True,false


Conversions between basic data types:
is converted according to the range represented: Small range can be automatically converted to a large range of
A large range can only be cast to a small
Byte-->short-->int--->long--->float--->double
Char--->int
Note: When char, short, int participate in the operation, all data is automatically converted to type int and then the operation
Transformation:
1, (up) from left to right for automatic conversion
2, (top) from right to left for casting: Basic data type variable name = (basic data type) the value to be converted;

Data representation of type char:
1, ' A ', ' I '
Wrong: ' AB ', ' a '
2, 0-65535
3, ' \u0061 '
char c = ' a ';
char C = 65;
char c = ' \u0061 ';

II. Reference data types: classes, interfaces, enumerations, arrays


Homework Today:
1. Please write out 10 valid identifiers
abc_$, _123, $aA, $_a_, Gonincon, Emnu_for, Noo$yss, _43_2, a_2_$, $$_$$_$$$_$$,

2. Please write out 5 illegal identifiers
123_ACD, double, void,%%_$$, Interface_noo, _$-add,


3, please write a program, output their own motto
public class Cheng
{
public static void Main (string[] args)
{
System.out.println ("My motto is: Persistence is victory!!!" ");
}
}

4. Memory Main method


Tomorrow content:
Variable
Operator
Binary conversion
An expression

Branch
Cycle

Thousand Peaks training Day01-java Basic Learning: history, data type

Related Article

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.