Joke Collection Website - Joke collection - What does jvv do?
What does jvv do?
Java is an object-oriented programming language.
Java is a widely used network programming language and a new computing concept.
First of all, as a programming language, it is simple, object-oriented, independent of the structure of the machine, portable, robust and safe, and provides a high-performance concurrency mechanism. Secondly, it makes full use of the network, and Java applets can be transmitted on the network, which is not limited by CPU and environment. In addition, Java also provides a wealth of class libraries, so that programmers can easily build their own systems.
Let's first discuss the characteristics of Java from these three aspects, and then further point out its advantages by comparing Java with C and C++.
First, the Java language
Java language has the following characteristics: simple, object-oriented, distributed, interpretable and executable, robust, secure, architecture neutral, portable, high performance, multithreading and dynamic.
1. Simple
Java language is an object-oriented language, which provides the most basic method to complete the specified tasks. Only by understanding some basic concepts, it can be used to write applications suitable for various situations. Java omits vague concepts such as operator overloading and multiple inheritance, and greatly simplifies the memory management of programmers by realizing automatic garbage collection. In addition, Java is also suitable for running on small computers. Its basic interpreter and class support is only about 40KB, and the support of standard class libraries and threads is only about 2 15KB. The support of libraries and threads is only about 2 15KB.
2. Object-oriented
The design of Java language focuses on objects and their interfaces, providing a simple class mechanism and a dynamic interface model. The object encapsulates its state variables and corresponding methods, realizing modularity and information hiding; Class provides the prototype of the class, and through the inheritance mechanism, subclasses can use the methods provided by the parent class to realize code reuse.
Step 3 distribute
Java is a network-oriented language. The class library it provides can handle TCP/IP protocol, and users can easily access other objects on the network through URL addresses.
4. Stability
When compiling and running programs, Java should check possible problems to eliminate errors. It provides automatic garbage collection for memory management to prevent programmers from making mistakes when managing memory. Through the integrated object-oriented exception handling mechanism, Java prompts possible but unhandled exceptions at compile time, helping programmers make correct choices and preventing system crashes. In addition, Java can also catch many common errors in type declarations at compile time to prevent mismatches in dynamic runtime.
5. Security
Java used in network and distributed environment must prevent virus invasion. Java does not support pointers, and all accesses to memory must be realized through instance variables of objects, thus preventing programmers from accessing private members of objects through deceptive means such as "Trojan Horse" and avoiding errors that are easy to occur in pointer operation.
6. Building neutrality
The Java interpreter generates bytecode instructions that are independent of the architecture. As long as the Java runtime system is installed, Java programs can run on any processor. These bytecode instructions correspond to representations in the Java virtual machine. After the Java interpreter gets the bytecode, it converts it so that it can run on different platforms.
7. Lightweight
Platform-independent features enable Java programs to be easily transplanted to different machines on the network. At the same time, Java's class libraries also realize the interface with different platforms, which makes these class libraries portable. In addition, the Java compiler is implemented by Java language, and the Java runtime system is implemented by standard C, which makes the Java system itself portable.
8. Explain the implementation
The Java interpreter directly interprets and executes Java bytecode. Byte code itself carries a lot of compile-time information, which makes the connection process easier.
9. High performance
Different from other languages such as BASIC and TCL, the design of Java bytecode makes it easy to directly convert it into machine code corresponding to a specific CPU, thus achieving higher performance.
10. Multithreaded operation
The multithreading mechanism enables applications to execute in parallel, and the synchronization mechanism ensures the correct operation of data. By using multithreading, programmers can use different threads to complete specific behaviors without adopting the global event cycle mechanism, so it is easy to realize real-time interactive behaviors on the network.
1 1. Dynamic
The design of Java makes it suitable for the ever-developing environment. You can freely add new methods and instance variables to the class library without affecting the execution of user programs. Moreover, Java supports multiple inheritance through interfaces, which makes it more flexible and extensible than strict class inheritance.
Second, the Java applet
The characteristics of Java language enable it to make full use of the network. Applet is a small application of Java, which is a dynamic, secure and cross-platform network application. Java Applet is embedded in HTML language and published on the Internet through the homepage. When a network user accesses the applet of the server, these applets are transmitted from the network and then run in a browser supporting Java. Due to the security mechanism of Java language, once the applet is loaded, users can safely generate multimedia user interfaces or complete complex calculations without worrying about virus invasion. Although Applet can be downloaded from the Internet like pictures, sounds and animations, their formats are different from these multimedia files. They can receive users' input and make changes dynamically, not just the display of animation and the playback of sound.
Third, rich class libraries.
Java provides a large number of classes to meet the needs of networked, multithreaded and object-oriented systems.
The support provided by 1. language pack includes string processing, multithreading, exception handling, mathematical function processing and so on. It can be used to simply realize the running platform of Java programs.
2. The support provided by the utility package includes hash table, stack, variable array, time and date, etc.
3.I/O package uses a unified "stream" model to realize I/O in all formats, including file system, network and input.
4. The underlying network package is used to realize Socket programming.
5.GUI package implements GUI components of computers on different platforms, including windows, menus, scroll bars, dialogs, etc. , so that Java can be ported to computers on different platforms.
6. The network package supports the TCP/IP protocol of the Internet and provides an interface with the Internet. It supports URL connection and instant access to WWW, which simplifies the programming of user/server mode.
Fourth, Java and C, C++
Used for variable declaration, parameter passing, operators, flow control, etc. Java uses the same tradition as C and C++, which is convenient for programmers who are familiar with C and C++. At the same time, in order to realize its simplicity, robustness and security, Java abandoned many unreasonable contents in C and C++.
1. global variable
In Java programs, global variables cannot be defined outside all classes, and only public and static variables can be defined in one class to realize a global variable. For example:
Category global variable {
Public static global _ var
}
The variable global_var is defined as public static in class GlobalVar, so that other classes can access and modify the variable.
Java encapsulates global variables better. In C and C++, relying on global variables without encapsulation often leads to system crash.
Step 2 go to
Java does not support goto statements in C and C++, but uses exception handling statements such as try, catch and final instead of goto in C and C++ to handle jumps when encountering errors, which makes the program more readable and structured.
3. Pointer
Pointer is the most flexible and error-prone data type in C and C++. Pointer's operation on memory address often leads to unpredictable errors. At the same time, after explicit type conversion of a memory address, the pointer can access a private member in C++, thus undermining security and leading to system crash. Java has complete control over pointers, so programmers can't directly perform any pointer operations, such as converting integers into pointers or releasing a memory address through pointers. At the same time, the array is realized as a class in Java, which solves the error of array access out of bounds in C and C++.
4. Memory management
In C, programmers allocate and release memory through library functions malloc () and free (), while in C++, they allocate and release memory through operators new and delete. Releasing released memory blocks or unallocated memory blocks again will lead to system crash; Similarly, forgetting to release memory blocks that are no longer used will gradually exhaust system resources. In Java, all data structures are objects, and the memory heap is allocated to them through the operator new. The processing right of the object is obtained through new, but the actual memory allocated to the object may change with the running of the program. Java automatically manages this and collects garbage, which effectively prevents mistakes caused by programmers' misoperation and makes better use of system resources.
5. Support data types
In C and C++, for different platforms, compilers allocate bytes with different lengths to simple data types such as int int and float. For example, int is 16 bits in IBM PC and 32 bits in VAX- 1 1, which leads to the code's non-portability. However, in Java, these data types are always fixed.
6. Type conversion
In C and C++, pointers can be used for any type of conversion, which usually leads to insecurity. In Java, the runtime system should check the type compatibility of objects to prevent unsafe conversion.
7. Header file
In C and C++, class prototypes, global variables, library functions, etc. Declared by a header file. In large systems, it is very difficult to maintain these header files. Java does not support header files, and the types and access rights of class members are encapsulated in one class. The runtime system controls access to prevent operations on private members. At the same time, use the import statement in Java to communicate with other classes in order to use their methods.
8. Structure and linkage
All members of the structure and union in C and C++ are common, which brings security problems. There is no structure and union in Java, everything is encapsulated in classes.
9. Pretreatment
The codes implemented by macro definitions in C and C++ bring difficulties to the readability of programs. Macros are not supported in Java. It declares a constant through the keyword final to realize the definition of constants widely used in macro definition.
- Related articles
- My husband says I look like a pig. Don't you like it when I say that?
- Wonder woman's review model essay?
Wonder woman's wonder woman 20 17 was burned before it was released. Just watching the trailer makes many otaku extremely excited. I brought this to you. I hop
- Why are hard-working people often excluded?
- Kneeling for the name of an anime character must have three words.
- My boyfriend likes me to tell him jokes. Today, he is in a bad mood. I don't know what joke to tell. Which kind-hearted person has a joke to share? ...
- Why are Keji's legs so short?
- How does League of Legends mock the opposite side?
- A collection of 50 copywriting phrases suitable for cycling and making friends at night.
- What happened to the female guests who participated in If You Are the One?
- Which cartoons have dinosaurs?