Today's first contact java

xiaoxiao2021-03-05  47

Today, I first contacted Java. Although I have seen some books in the past, but most of them are itchy, I can't get it, I will never say I understand Java. When you get in contact with a new technique, it is the first time, but the different is that the latter will generally begin very sweet, but the ending is very painful, and the former is often very painful, but it is, but it is, but it is simply. It is still to stop. Now I am in this very painful stage, even a simplest HelloWorld can't run, always prompts ExcePion in thread "main" java.lan.noclassdeffounderror. I have to go online to check, go search. Remember Not good, so search quickly, always have no problems. Generally, after installing JDK, you must press the step configuration to correctly compile the run (assuming the JDK version is 1.4.0) 1. JDK1.4.0- Under the root directory of a drive letter of your machine, you can be installed in D: /. *** (The D: /J2SDK1.4.0_01 appeared below is changed to your own installation JDK directory) *** 2. If your running environment is Win98, in the root directory of the C drive, the autoexec.bat file, Join the following two statements: set path =% path%; D: /J2SDK1.4.0_01/bin set classpath = .; d: /j2sdk1.4.0_01/lib/dt.jar; D: /J2SDK1.4.0_01/lib After /Tools.jar saves, restart the machine to complete the installation of JDK1.4. 3. If your running environment is Win2000, you need to add two user variables to the Environment Variables of the "Advanced" option under "System" of the Control Panel. One of the user variables is "path", the value is ".; D: /J2SDK1.4.0_01/bin", the name of another user variable is "classpath", value ".; D" /j2sdk1.4.0_01 /LIB/dt.jar;d:/J2SDK1.4.0_01/lib/tools.jar ", click OK to complete the installation of JDK1.4.0. As for this meaning, I think it should be Let the Java system need a stupid support when compiling byte codes (.java), if you don't tell it which place in the Dongdong is put, it is stupid ?! See the Hello on the screen World is a significant significance. This is the first program I wrote in the past year! I will embark on the way to the program. It is like a feeling of separation. I have already found it. I have some original learning. About C and the object-oriented fur did not forget light, so after the time, after familiar with the JDK environment, the next thing is better, and the heart is more practical. Direct define string variables directly with Class C The typical pointer, I feel very good, I am used to Object Pascal, if I go back to the number * *, I really want to be crazy. The definition and C, C seems slightly different, I can't remember, first Remember to say int [] number = new int [5] string [] message = new string [5] variable This part of this part is so much. Although it is a rookie, but I also know that it is always like Tan Haoqiang. People who die on the grammar are simply idiot: In most cases, the beautiful procedures do not need unnecessary embellishments, the work is complete, and the ideas can be clear. Pouring the framework of the Java program, I want to make form, A simple Java program seems to be such a frame class programname {public static void main (String [] args) {// program main body} public static int}}} Other Method}} The entire program is in a big In the class, the concept of this class should be almost almost in the cells in Pascal.

Like PASCAL, the file name is also with the unit name - here is a class name - the same. Java is very strict, I am wrong for the case, I am wrong because this. Java program is made by one or more or many A method is composed of such a large class. In the above code, the parameter representation of the definition method indicates that this member function is public, and the other class is directly called Static to represent the main member function in the ProgramName class. All objects are unique, Java will allocate permanent storage space (January 17) About static, I want to extend again. Sometimes we create a class, I hope all instances of this class use a variable, that is, all such class objects have a copy of the instance variable. Then such a static instance variable is not available to the instance of the creation. When you assign it, because everyone used it, it does not need to be reassigned again. Therefore, Java assigns permanently stored space. For example, Class Block {static int number = 50} After this definition, all Block-class instances, whether it is block1, or block2, they all access the same number. This Number called a variable, not instance variables. Actually static Variables are also called class variables. (January 17) continues to deepen. Use static member functions or static variables defined by Static, you can call them directly through the class name. Why can you do this? Because since all objects of this class are used, then I don't need to go to any object from it to reference it, but it is just a reference to the class name. Isn't it convenient to implement some full-class functions and global variables? All global functions or global variables Define in a static class, you can easily access all global variables and global functions when calling this class name. (January 20) Defines all programs to access global variables to use public final static In addition, it is often incomplete non-static variable why it is often encountered by an initiator often encountered. Non-Static Variable MainFrame Cannot Be Reference from A Static Context. Because we know that the static method can be used when not created an instance, and the state of the non-static member variable is an object property, which is only referenced when the object exists, so we call it in the static method if it is not created in the object. Non-static member methods are naturally illegal, so the compiler will give each time this time. Simply, the static method can call it without creating an object, the non-static method must have an object's instance to be called. So I want to static The reference non-static method is impossible, because is the non-static method of which object is referenced? The compiler is impossible to give an answer, because there is no object, so we have to report the error. In the end, we look at Think in Java. Exquisite explanation, I think it is very clear about 2.6.3 static keywords, and we will indicate the appearance and behavior of the object when we create classes. Unless I created one object of that class with NEW, I actually didn't get anything. Data storage is formally generated after NEW, and the corresponding method can be used. However, in two special circumstances, the above method is not available. One situation is just to use a storage area to save a specific data - no matter how many objects to create, even simply do not create objects. Another situation is that we need a special method that does not associate any objects of this class. That is to say, even if the object is not created, a method of calling can be called. To meet these two requirements, STATIC keywords can be used. Once there is something set to static, data or methods, it will not be contacted with any object instances of the class. So although an object that has never created that class, you can still call a static method or access some STITIC data. Before this, for non-Static data and methods, we must create an object and use that object to access data or methods.

转载请注明原文地址:https://www.9cbs.com/read-36721.html

New Post(0)