Java Learning Notes (1): Basic knowlege points

Source: Internet
Author: User

Basic knowlege points:

1:it ' s necessary that there are only one public class in per. java file

2:. java file name should better to same as class name

3:when set the environment variable CLASSPATH, you should make sure the '. ' Path can ' t is lack of.

4:java is case sensitive, including. java file name, class name, variable name, method name and so on.

5:JVM uses automatic garbage collection machanism. It just collects memory source, not contains physical source, such as database connection, disk IO. You can invoke a collection through call static method System.GC ().

6:java is Strong-type language, the variable shouble being declared firstly and then you can use it. ②the Vairable only can accept the value which type was consistent with itself.

7:/** */is used to add document annotation for Java. Javadoc command can export the code API document.

8:use ' ... ' follow method parameter type, means have at least one parameter or more parameter. It equals type array type[]. It ' s similar with the params in C #

9. In Java, LAMDA expression use '-' symbol

From Java 7, switch statement is allow the use of String type, before just includes byte, int, char, shot four type.

11.For Java, object instance can access the class static method or static field. But in C #, that ' s illegal.

For Java, the package is similar with namespace in C #

For classes they belongs to same packege, don ' t has to be at the same directory. That means there can is several packages with same name, but these packages should at different directory. The and. class file should at the directory which name are same with their package name.

In Java, 'instanceof' keyword equals ' was 'in C #; There isn ' t keyword like ' as '.

In Java, the support initialization block, and Don ' t in C #.

public class A

{

{... block}

}

Note:the Execute order is that:create class object, initialize block, initialize field, constructor

If all class object has same logic, or initialize code, we can use static initialization block

In Java, final keyword are same as sealed in C #.

The relationship of basic type with their packaged class

When convert between basic type with packaged class, system would boxing or unboxing automatically.

. For value type and reference type which be defined by 'final' keyword ', difference is following:

1. final value type can ' t be changed or modified anymore.

2. final reference type ' reference which is pointer address are can ' t changed, but the object fields can be Modifi Ed or changed.

Note:it ' s same as 'readonly' key word and 'const' key word in C #.

. Object Reference:

1. Strongreference----When system collect garbage, the object is not being recycled.

2. weakreference ----When system collect garbage, the object would be recycled compulsively.

3. phatomreference -----The object would be recycled compulsively. It can ' t get object address reference use phatomreference. It just to use to trace the object.

4.softreference ------When system collect garbage, if the memory was not enough, the object would be recycled compulsively.

Note:it ' s alse same as WeakReference in C #

Java Learning Notes (1): Basic knowlege points

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.