Language Overvie As we stated earlier,Java is based on C++ but was specifically designed to be smaller,simpler,and more reliable. Java has both types and classes. The primitive types are not objects based on classes. These include all of its scalar types, including those for integer,floating-point,Boolean,and character data.Objects are accessed through reference variables,but primitive type values are accessed exactly as the scalar values in purely imperative language like C and Ada 83.Java arrays are instances of a predefined class,whereas in C++ they are not ,although many C++ users build wrapper classes for arrays to add features like index range checking,which is implicit in Java.40843
Java does not have pointers,but its reference types provide some of the capabilities of pointers.These references are used to point to class instance,in fact,that is the only way class instances can be referenced.All objects are allocated on the heap.While pointers and references may seem a great deal alike,there are some important semantic differences.Pointers point to memory locations,but references point at objects.This makes any kind of arithmetic on references nonsense,eliminating that error-prone practice.The distinction between a pointer’s value and the value to which it points is the responsibility of the programmer in many languages,in which pointers sometimes must be explicitly dereferenced.References are always implicitly dereferenced,when necessary.So they behave more like ordinary scalar variables.
Java has a primitive Boolean type,used mainly for the control expressions of ints control statements(such as if and while).Unlike C and C++,arithmetic expressions cannot be used for control expressions.Java has no record,union,or enumeration types.
One significant difference between Java and many of its contemporaries that support object-oriented programming,including Ada 95 and C++,is that it is not possible to write stand-alone subprograms in Java.All Java subprograms are methods and are defined in classes.There is no construct in Java that is called a function or a subprogram.Furthermore,methods can only be called through a class or object.
Another important difference between C++ and Java is that C++ supports multiple inheritance directly in its class definitions.Some feel multiple inheritance leads to more complexity and confusion than it is worth.Java supports only single inheritance,although some of the benefits of multiple inheritance can be gained by using its interface construct.
Java includes a relatively simple form of concurrency control through its synchronize modifier,which can appear on methods and blocks.In either case,it causes a lock to be attached.The lock insures mutually exclusive access or execution.In Java it is relatively easy to create concurrent processes,which in Java are called threads.
Java used implicit storage deallocation for its object,often called ‘garbage collection’.This frees the programmer from being concerned with putting storage back in the heap when it is no longer needed.Programs written in language that require explicit deallocation often suffer from what is sometimes called memory leakage,which means that storage is allocated but never deallocated.This can obviously lead to eventual depletion of all available storage.
Unlike C and C++,Java includes assignment type coercions (implicit type conversions ) only if they are widening (form a “smaller” type to a “larger” type).
Java in the memory allocation is dynamic, it uses object-oriented mechanism and the actual memory will be with the operation of the program. Program to run in the Java system automatic memory were scanned as long-term unused space of "garbage collection, so that system resources are more fully utilized. According to this mechanism, programmers do not have to pay close attention to the problem of memory management, which makes Java programming makes it simple and clear, and avoid the errors due to memory management and lead to system problems.
- 上一篇:酒店业的管理创新英文文献和中文翻译
- 下一篇:云计算英文文献及中文翻译
-
-
-
-
-
-
-
java+mysql车辆管理系统的设计+源代码
当代大学生慈善意识研究+文献综述
杂拟谷盗体内共生菌沃尔...
电站锅炉暖风器设计任务书
大众媒体对公共政策制定的影响
中考体育项目与体育教学合理结合的研究
河岸冲刷和泥沙淤积的监测国内外研究现状
乳业同业并购式全产业链...
十二层带中心支撑钢结构...
酸性水汽提装置总汽提塔设计+CAD图纸