In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what are the basic knowledge of Java". In daily operation, I believe many people have doubts about the basic knowledge of Java. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the questions of "what is the basic knowledge of Java?" Next, please follow the editor to study!
Java is a high-level programming language introduced by Sun Microsystems in May 1995.
Java can run on multiple platforms, such as Windows, Mac OS, and many other UNIX versions of systems.
Create a java file (the file name must be the same as the class name)
Both String args [] and String [] args can be executed, but String [] args is recommended to avoid ambiguity and misreading.
:::
Introduction to Java
Java is the general name of Java object-oriented programming language and Java platform introduced by Sun Microsystems in May 1995. It was jointly developed by James Gosling and colleagues and officially launched in 1995.
Java is divided into three systems:
JavaSE (J2SE) (Java2 Platform Standard Edition,java platform Standard Edition)
JavaEE (J2EE) (Java 2 Platform,Enterprise Edition,java platform Enterprise Edition)
JavaME (J2ME) (Java 2 Platform Micro Edition,java platform Micro Edition).
In June 2005, the JavaOne conference was held, and SUN made Java SE 6 public. At this point, various versions of Java have been renamed to cancel the number "2": J2EE has been renamed to Java EE, J2SE has been renamed Java SE,J2ME to Java ME.
.
Main characteristics
The Java language is simple:
The syntax of Java language is very similar to C language and C++ language, which makes it easy for most programmers to learn and use. On the other hand, Java discards difficult and confusing features rarely used in C++, such as operator overloading, multi-inheritance, and automatic casting. In particular, the Java language does not use pointers, but references. It also provides automatic garbage collection so that programmers do not have to worry about memory management.
2. Java language is object-oriented:
Java language provides object-oriented features such as classes, interfaces and inheritance. For simplicity, it only supports single inheritance between classes, but supports multiple inheritance between interfaces, and supports the implementation mechanism between classes and interfaces (keyword is implements). Java language fully supports dynamic binding, while C++ language only uses dynamic binding for virtual functions. In a word, Java is a pure object-oriented programming language.
3. Java language is distributed:
Java language supports the development of Internet applications. There is a network application programming interface (java net) in the basic Java API, which provides class libraries for network application programming, including URL, URLConnection, Socket, ServerSocket and so on. Java's RMI (remote method Activation) mechanism is also an important means of developing distributed applications.
4. Java language is robust:
Java's strong typing mechanism, exception handling and automatic garbage collection are important guarantees for the robustness of Java programs. Discarding pointers is a wise choice for Java. The security checking mechanism of Java makes Java more robust.
5. Java language is secure:
Java is usually used in the network environment, for this reason, Java provides a security mechanism to prevent malicious code attacks. In addition to many security features of the Java language, Java has a security mechanism (class ClassLoader) for classes downloaded through the network, such as assigning different namespaces to prevent replacing local classes of the same name, bytecode checking, and providing a security management mechanism (class SecurityManager) to allow Java applications to set security sentinels.
6. The Java language is architecture neutral:
Java programs (files with the suffix java) are compiled into an architecture-neutral bytecode format (files with the suffix class) on the Java platform, and can then be run on any system that implements the Java platform. This approach is suitable for heterogeneous network environment and software distribution.
7.The Java language is portable:
This portability stems from architectural neutrality, and Java strictly specifies the length of each basic data type. The Java system itself also has strong portability. The Java compiler is implemented in Java and the running environment of Java is implemented in ANSI C.
8. The Java language is interpretive:
As mentioned earlier, Java programs are compiled into bytecode format on the Java platform and can then be run on any system that implements the Java platform. At run time, the Java interpreter in the Java platform interprets and executes these bytecodes, and the classes needed during the execution are loaded into the runtime during the join phase.
9. Java is of high performance:
Java is indeed high-performance compared to those interpreted high-level scripting languages. In fact, the running speed of Java is getting closer and closer to that of C++ with the development of JIT (Just-In-Time) compiler technology.
10. The Java language is multithreaded:
In the Java language, a thread is a special object that must be created by the Thread class or its descendant class. There are usually two ways to create a thread: one is to wrap an object that implements the Runnable interface into a thread using a constructor of type Thread (Runnable), and the other is to derive a subclass from the Thread class and override the run method, and the object created using that subclass is a thread. It is worth noting that the Thread class already implements the Runnable interface, so any thread has its run method, and the run method contains the code that the thread wants to run. Thread activity is controlled by a set of methods. The Java language supports simultaneous execution of multiple threads and provides a synchronization mechanism between multiple threads (keyword is synchronized).
11. Java language is dynamic:
One of the design goals of Java language is to adapt to the dynamic environment. The classes needed by Java programs can be dynamically loaded into the runtime environment, or the required classes can be loaded through the network. This is also conducive to software upgrade. In addition, the classes in Java have a run-time representation that can perform run-time type checking.
.
History of development
On May 23, 1995, the Java language was born.
In January 1996, the first JDK-JDK1.0 was born.
In April 1996, the 10 leading operating system vendors announced that they would embed JAVA technology in their products.
In September 1996, about 83000 web pages were created using JAVA technology.
On February 18, 1997, JDK1.1 released
On April 2, 1997, the JavaOne meeting was held with more than 10, 000 participants, setting a record for similar meetings in the world at that time.
In September 1997, the members of the JavaDeveloperConnection community exceeded 100, 000
In February 1998, JDK1.1 was downloaded more than 2000000 times.
JAVA2 enterprise platform J2EE was released on December 8, 1998.
In June 1999, SUN released three versions of Java: the Standard Edition (JavaSE, formerly J2SE), the Enterprise Edition (JavaEE formerly J2EE), and the Micro Edition (JavaME, formerly J2ME)
On May 8, 2000, JDK1.3 released
JDK1.4 released on May 29th, 2000
On June 5, 2001, NOKIA announced that it would sell 100 million Java-enabled mobile phones by 2003.
On September 24th, 2001, J2EE1.3 released
On February 26th, 2002, J2SE1.4 released, since then the computing power of Java has been greatly improved.
On Sept. 30th, 2004, the release of J2SE 1.5 of 18 00PMMJ became another milestone in the history of Java language development. To show the importance of this version, J2SE1.5 changed its name to Java SE 5.0
In June 2005, the JavaOne conference was held, and SUN made Java SE 6 public. At this point, various versions of Java have been renamed to cancel the number "2": J2EE renamed Java EE,J2SE to Java SE,J2ME renamed Java ME
In December 2006, SUN released JRE6.0
On April 20, 2009, Oracle acquired Sun for $7.4 billion. Obtain the copyright of java.
In November 2010, Apache threatened to quit Java because of Oracle's unfriendliness to the JCP community.
On July 28th, Oracle released the official version of java7.0.
On March 18, 2014, Oracle released Java SE 8.
.
Java development tools
The Java language tries to ensure that there is more than 1G in the system. Other tools are as follows:
Linux system, Mac OS system, Windows 95, 98, 2000, XP, win, 7, and 8 systems.
Java JDK 7, 8...
Notepad editor or other editor.
IDE:Eclipse
After installing the above tools, we can output Java's first program, "Hello World!"
:::
Basic syntax of Java
A Java program can be thought of as a collection of objects that work together by calling each other's methods. The following briefly describes the concepts of classes, objects, methods, and instance variables.
Object: an object is an instance of a class that has state and behavior. For example, a dog is an object, its status is: color, name, breed; behavior: wagging tail, barking, eating and so on.
Class: a class is a template that describes the behavior and state of a class of objects.
Method: a method is a behavior, and a class can have many methods. Logical operations, data modifications, and all actions are done in the method.
Instance variables: each object has unique instance variables, and the state of the object is determined by the values of these instance variables.
.
Basic grammar
When writing Java programs, you should pay attention to the following points:
Case-sensitive: Java is case-sensitive, which means that the identifier Hello is different from hello.
Class name: for all classes, the first letter of the class name should be capitalized. If the class name consists of several words, the first letter of each word should be capitalized, such as MyFirstJavaClass.
Method name: all method names should start with lowercase letters. If the method name contains several words, the first letter of each subsequent word is capitalized.
Source file name: the source file name must be the same as the class name. When saving a file, you should use the class name as the file name (keep in mind that Java is case-sensitive), with the suffix .java. (if the file name and class name are different, it will result in a compilation error)
Main method entry: all Java programs are executed by the public static void main (String [] args) method.
.
Java identifier
All components of Java need names. Class names, variable names, and method names are all called identifiers.
With regard to Java identifiers, there are the following points to note:
All identifiers should start with a letter (Amurz or amurz), a dollar sign ($), or an underscore (_).
The first character can be followed by a letter (Amurz or amurz), a dollar sign ($), an underscore (_), or any combination of numbers
Keyword cannot be used as an identifier
Identifiers are case sensitive
Examples of legal identifiers: age, $salary, _ value, _ _ 1_value
Examples of illegal identifiers: 123abc,-salary
.
Java modifier
Like other languages, Java can use modifiers to modify methods and properties in a class. There are two main types of modifiers:
Access control modifiers: default, public, protected, private
Non-access control modifiers: final, abstract, strictfp
.
Java variable
There are mainly the following types of variables in Java
Local variable
Class variable (static variable)
Member variables (non-static variables)
.
Java array
An array is an object stored on a heap that can hold multiple variables of the same type. In later chapters, we will learn how to declare, construct, and initialize an array.
.
Java enumeration
Java 5. 0 introduces enumerations, which limit variables to pre-set values. Use enumerations to reduce the bug in your code.
For example, we design a program for juice shops that will limit juice to small, medium and large. This means that customers are not allowed to order fruit juices other than these three sizes.
At this point, the study of "what are the basic knowledge of Java" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.