Joke Collection Website - Cold jokes - Why does the container simple program in java appear the following prompt at compile time?
Why does the container simple program in java appear the following prompt at compile time?
public & gtpublic Main() {
}
Public static void main(String[] args) {
HashMap hm = new HashMap();
hm.put(" 1 ", 1 1);
system . out . println(hm . get(" 1 "));
}
}
When compiling with java 1.5, it will appear:
Note: Main.java uses unchecked or unsafe operations.
Note: For more information, please recompile with -Xlint:unchecked.
This warning appears because:
Because java 1.5 uses generics, the following changes have been made:
HashMap hm = new HashMap();
Change to:
HashMap & ltString,Integer & gthm = new HashMap & ltString,Integer & gt();
Do it.
So what is generics?
Generic programming allows you to write completely universal and reusable algorithms with the same efficiency as those designed for specific data types. STL is a representative work of generic programming and an efficient, universal and interoperable software component. The so-called generics can operate on various data types, which is somewhat similar to templates. STL is huge and extensible. It contains many basic computer algorithms and data structures, and completely separates the algorithms from the data structures. Among them, the algorithm is universal and does not depend on any specific data structure or object type. STL is a general algorithm library based on iterator and container. The existence of containers makes these algorithms operable. STL includes various general algorithms, general pointers, general containers and function objects. STL is not only a collection of useful components, but also a formal and organized architecture, which describes the abstract requirements of software components.
Dare to ask, is your jdk path set incorrectly or something else? My computer is all right. Please check your jdk settings and go to the directory where the file is located to execute javac and java commands. Please refer to the following articles:
==================================================
JDK installation setting environment variables
I. Introduction
JDK(java Development Kit) is the foundation of all java applications, and it can be said that all java applications are built on it. It is a set of APIs, or some java classes. The latest version that has been officially released is JDK 1.3. Considering that I am not familiar with linux, and most of them are under MS system, I use win2000 here.
Second, download and install.
The download address is the official JAVA website: java.sun.com, which can be found everywhere in China.
Under Windows, run. Exe file and install it in a directory. Let me take F:\jdk 13 as an example.
Third, configuration
Select "My Computer" on the desktop (right click).
elder
envionment variables
In "system variables"->; "New"
Enter: CLASSPATH in the variable name, and then enter:
F:\JDK 13\LIB\dt。 Jar; F:\JDK 13\LIB\TOOLS。 Jar; f:\ JDK 13 \ BIN; Then determine;
Well, after the configuration is completed, the environment variables will not take effect until the computer is restarted.
Fourth, testing.
(1) Write a simple java program with a text editor;
Public class HelloWorld {
Public static void main (strinargs []) {
System.out.println("Hello World!" );
}
}
This example is the famous "Hello World", and its function is to display "Hello World".
Note: The file name must be "HelloWorld.java" and be case-sensitive. Careful friends will notice that it is the same as the name after the open class.
(2) Compile: Execute at dos command prompt: (Note case)
Javac HelloWorld.java
If it is normal, the HelloWorld.class file will be generated.
(3) Run: Execute at dos command prompt: (Note case)
java HelloWorld
Here is a problem that beginners of java are likely to encounter (I am not afraid of jokes, so am I): Enter:
java HelloWorld.class
Pay attention to the extra. Class, otherwise the following error will occur:
Exception in thread "main" java.lang.noclassDefoundError: hello world/class.
I guess it was translated by java. "With"/",or for other reasons I don't know)
Well, running java HelloWorld should produce a great "HelloWorld".
At this point, you have successfully configured the JDK, and you can start the long and painful java process (for a friend like me who didn't know Java before, you can describe it as "pain", a strange concept, a strange java api ... but don't worry, I will get started slowly with you and improve slowly ...).
- Previous article:When educating children, parents must pay attention to the way their children speak.
- Next article:Is there a short joke?
- Related articles
- The little joke about technology is urgent! ! !
- Will getting married without a wedding be laughed at?
- Sentences about not wasting one's life
- Which is more expensive, green mountain coffee or Blue Mountain Coffee?
- Horse word xiehouyu
- List of 100 words and deeds of primary and secondary school teachers in Wuhai City
- On the first day of the young man's work, the boss rolled his eyes with the rich woman at the meeting and took a fancy to this TV series.
- Spring Festival is a traditional festival in China. Do you know the custom of celebrating the Spring Festival in your hometown?
- Kneel for the wonderful novels of system class and infinite flow or infinite plus system.
- How to add friends to the gunfight king