Java BASICS (some basic concepts)

Source: Internet
Author: User

1. java Basics
A) How does one configure java environment variables in the operating system?
1) install jdk;
2) Add the bin address in jdk to the running environment:
A. Right-click the computer and click Properties;
B. Click environment variables;
C. Find the path and double-click it;
D. Add an English score ";" after the original address.
E. paste the bin address after it;
F. Click "OK.
B) What should I pay attention to when naming classes, attribute names, method names, and constant names?
Try to use the approximate English name words.
1). the class name must start with an upper-case letter and the other letters in the word must be lower-case. If the class name is composed of multiple words, the first letter of each word should be upper-case. For example: DrawFrame
2) When naming an attribute, pay attention to the use of private restrictions.
3). The first word of the method name should start with a lowercase letter, and the subsequent words should start with an uppercase letter. Eg: showUI
4). The constant names should all use uppercase letters and indicate the complete meaning of the constant. If a constant name is composed of multiple words, the words should be separated by underscores. Eg: MAX_VALUE
C) must the class name be the same as what?
Same as file name
D) how to compile and run Java commands and formats?
Compile: javax file name. java
Run: java file name
E) What are the basic data types in Java?
Data Type
English expression
Bit (bit in computer)
The value range is n: bit-2 ^ (n-1 )~ 2 ^ (n-1)-1
Byte type
Byte
8bit
-128 ~ 127
Character Type
Char
16bit
0 ~ 65535
Boolean
Boolean
--
--
Short integer
Short
16bit
-2 ^ 15 ~ 2 ^ 15-1
Integer
Int
32bit
-2 ^ 31 ~ 2 ^ 31-1
Floating Point Type
Float
32bit
Long Integer
Long
64bit
-2 ^ 63 ~ 2 ^ 63-1
Double Precision
Double
64bit
Memory: The character length is not short, and the positive and double characters are long.
Byte string Boolean short integer
Integer floating point type long integer Double Precision
F) which data types are available in Java?
Original object type
Object Type generated by class
G) What are the common methods of String?
Class
2. Classes and objects
A) Class Definition
Class is a prototype that defines variables and methods for certain types of objects.
A class consists of two key parts: method and attribute.
B) object definition
Objects are class instantiation.
C) define the format of the class
Public class name (parameter (optional )){
Class body
}
D) Format of the created object
Class Name object name = new Class Name ();
E) classification of methods
1). Return Value Based on the Method: A: Method with return value eg: public String getName (){
Return name
}
B: method without return value
2). A: There are parameter Methods
B: No Parameter Method
F) method Overloading
In a class, multiple methods with the same name but different parameter types or quantities can be defined.
G) constructor
Constructor is a special method used to initialize an object when creating an object, that is, assigning an initial value to the object member variable, the new operator is used together with the new operator. In the statement for creating an object, a special class can have multiple constructors to distinguish them (constructors) based on the number of parameters or different parameter types..
H) value transfer
When a method is called, the actual parameter passes its value to the corresponding formal parameter. The change of the formal parameter value during method execution does not affect the value of the actual parameter.
I) Transfer references
When calling a method, the passed parameters are passed by reference.
J) this keyword
Indicates the current object in the class.
<! -- EndFragment -->

Author: "flycatdeng"
 

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.