In recent days, watching Java video, I feel a lot of things Java syntax is like C #, but there are a lot of things surprised me:
1,java virtual machines
Children's shoes with Vmwar or VirtualBox have a general understanding of the word "virtual machine", and virtual machines provide a virtual platform that allows us to simulate some environments that are out of the hardware. Virtual machines in Java play a similar role as previously learned ODBC drivers, it masks the underlying differences, so that the operating system through the virtual machine to see below, the operating system feel is the same.
With this layer of stuff, we've completely unlocked the coupling between the underlying hardware and the running operating system, achieving a dream of compiling, running around. The decoupling thought here is consistent with the layered thinking of software.
If you want to make all levels flexible, then add an interface between them.
2, data type
In the basic data type, mine is the array and string is the reference type, it seems that my C # is not solid Ah, Baidu a bit, C # is like this, they are reference types;
The difference between the basic type and the reference type's memory access is discussed first: You can fetch the value directly when accessing the base type, and the reference type must first fetch the heap's address from the stack, then run into the heap to fetch the actual value, and from the memory access, the reference type does not seem to have the advantage of a value type.
But from an object-oriented perspective, there are many benefits to reference types:
A. The reference type can be serialized, not the original type. (This does not understand!) )
B. The method provided by the reference type can be flexibly converted, can be extended, the original type does not
C. Only objects can be used in the collection class, not the original type
D. There is no concept of NULL for primitive types, there are cases where it is necessary to tell if a parameter is initialized, and if the original type is used, then the value of 0 does not know whether it is the initial value or if it is not initialized by the system automatically.
With respect to the two data types, the invariant parts of the basic data type programming language are used in a variable and invariant way, whereas reference types are types that are dynamically combined to deal with objects in the world of display.
3, the return value problem of the constructor function
When I used to learn C + +, I encountered many constructors ' initialization class members. This time in the study of the constructor here, in the video in order to illustrate the constructor does not return the value of the problem, deliberately added void for the constructor, the result is an error. But have you ever wondered why a constructor has no return value? or the return value of the constructor has a default value that cannot be changed, which is the object itself. Consider that when we use new, Dog d=new Dog (), the thing behind new is the constructor that is called, and it returns D.
So, can we assume that because the constructor of a class has a default return value and cannot define its own return value?
Summary: Object-oriented language to now have learned vb.net, C #,c++, this time to Java learning, is the object-oriented knowledge of a re-carding and summarize the process of ascension, but also to recognize the encapsulation, inheritance, polymorphism, abstraction, and re-think about them process.
Java Basic Learning--on object-oriented re-knowledge