My Java learning experience talks 2

xiaoxiao2021-03-05  28

Article 2: Programming Getting Started

The last time I said the environmental configuration, and I have been in the past few days, and I have said that I have said some basic knowledge of programming, and share my experience! I declare that my own programming level is very limited, ^ _ ^, so I said to let everyone understand, as far as I don't want to say, because I am afraid that I am not allowed, I have delayed everyone. Learning, as for the place, please, please point out, save the new people to see the conceptual confusion! The purpose of my article is basically literate, wants more brother sisters to get into the programmed door early, save every day, the second trafficker of the computer company is one or two variables every day, and the function is giving the dizzy! To tell the truth, the domestic programmer is now a lot! But there is not much strength, most of the knowledge of the semi-solving, depends on the source code (or the source code of the ASP), modify the modification of the mixed food (in fact everyone just modify the webpage)! So you are now intended to deal with computer companies, often by their advanced "B-S" program demonstration, I often do this before going abroad! I use the language as possible, the purpose is to let everyone understand the programming, as long as your English can pass the four levels, the high can be more than 60 points, then your IQ is not a programmed door. Programming is difficult, as long as it enters the door, then look at your true skills, the program is actually a tool, creative, imagination, as long as you can master the tools in your hands, give full play to your brain Wisdom! There is a saying that I forgot in which post is seen, it is very classic. Here, I will give you Show Show. "Say Java, can not mention the Chinese programmer, conservative estimate inside Sun company, Java at least 70 % Is developed by Chinese, so Java is 70% of China's manufacturing is not blame. As for Microsoft's Windows, that playground may be 100% of China! It is purely "domestic software"! "Chinese The world's most expensive software, the same Chinese also compiled the world, but the most popular compiler! So you, the future is in your hands! Ha ha……..

After it, I am excited is Rubbish, which is just to let everyone feel excited with me. The most important thing to learn anything is passion. First, let everyone hang up, you should not be difficult. Good It is said that it is the foundation of the programming today.

Speaking of the procedure, you have to mention, Feng - Nogan structure, listening to me with you in English, in fact, this structure is also very simple, is divided into two parts: information and instructions, information It is the data we want to calculate, the instruction is how we calculate these data. Bicard: I gave you 100 yuan, or I give you 100 dollars, let you find a way to put it out, you have donated 100 yuan to the Southeast Asian tsunami, or you went to Thailand to see $ 100 Strip Dance (your boy is really double personality). This leads out the basic classification of information and instructions, and the instruction is divided into: order, selection, and repetition. It is better than your boy to donate, or you can see strip; information is divided into: numbers, characters, strings .... It is better than I can give you the renminbi, or give you the dollar. So don't look at our first source of sources, there are two piles, in fact, there are two things, data and instructions, and this program is broken down:

Import java.lang. *; public class

Lee

{Public Static

void main (string [] args) {system.out.print ("Java is very easy !!!

");

It is the first procedure we speak, but it is really uncomfortable this, we change it slightly:

Import java.lang. *;

Public class lee

{

Public static void main (string [] args)

{

System.out.print ("

Java Is Very Easy !!! ");

}

}

If you write, you will look more, but you can understand, so you must develop a good habit when you write the program, try to let others see some of your procedures, to make it, structure, clear Ordered.

Ok, let us analyze our first program (the word of the black body is the program.):

PUBLIC CLASS Lee {

Public static void main (string args []) {

System.out.println ("Java Is Very Easy !!!");

}

}

In Java, it is convenient to see, the name of the class we all have uppercase letters! Which of you can find a program? ? correct,

Lee

String

SYSTEM

These are probably the name of the class, but now it is convenient, string and system, you don't want to tannam, let's talk about Lee. (Note, Lee here is my dear far from the domestic cousin SIR name).

If you want to speak, it is involved in object-oriented applications. When you listen to everyone, you will always look at someone on the website, it seems to be very deep, in fact, it is very simple, my computer computer The translation of the book is really darent, can't say, I can only say a few translations. I don't understand those who are talking about using English. I am translated in China. I am really deep. People don't understand, the professional terminology is a lot, it seems to be tested my logical thinking. You go to see the tutorial above the Sun website (all free !!!), basically do not exceed the vocabulary of high school, and understand it is easy (of course, you have to graduate high school !!), all special bats So learning Java or the old topic I repeated, you next Jinshan Word 2005, then find a tutorial to java.sun.com, you don't have to look at my article at all, because the above is simple, It is easy to understand! Ok, it's a lot of nonsense, I will follow the object, play an alteration, one object inside, you will see it as a person, this person will certain skills. The object is a class in Java, a class is an object. So according to the above example Lee is a person, this person only has a skill in the program we have written, because we wrote a skill to it, of course, we can also give him more skills, this is a later words. ! We will start from the first line:

PUBLIC CLASS Lee {

The mean of this is true that we have created a class, name is Lee, so that we have created a person than us, his name is Lee,

Public class meaning is a public class, what is a public class? After you, you will die first, you remember that when you want to create a class, you will use it.

Public Class

The name of the class you want to create, and this name starts letter to your uppercase, this is the habit of everyone, of course, you don't write, but this is the name experience summed up, you come. Ok. The latter braces will indicate that our body begins back from this braces. The bracethrics and the last braces are pair, the brackets do not say that you should understand, indicating The end of our body.

Let's start talking about things inside:

Public static void main (string args []) {

System.out.println ("Java Is Very Easy !!!");

}

I just said, the object, that is, the class in Java, there should be some skills, how do these skills we give this class? We all write them inside the body.

Public static void main (string args []) This means I don't want to explain it now, this is a function of a function,

Public This word You already know, this sentence is: public static valueless main functions (). What you have to remember now is that all things that can be run independently have to have, it is quite with a person's life, there is a function, this class, that is, this is a living person. If we don't use people to fight, we exchange computers to fight, then this function is better than this computer, it can move itself. Of course, some categories don't have this function. It is like a dead person, a computer that has no electricity, but after this dead is alive, after the electric computer is connected, it can also achieve the skills they have! How to achieve it? You can use the class with this function, that is to say to find a living person, find a TV-free computer to call these dead and no electricity! Simply put, the class with the main function can run directly, and the class without the main function cannot be running directly. They create it to use the class of the main function. Now we give us a class that is given to life, giving it the same power, turn this:

PUBLIC CLASS Lee {

Public static void main (string args []) {

}

}

because

Public static void main (String Args []) function is only given to the class, does not give special capabilities to classes, let us give us a special ability to give special capabilities:

PUBLIC CLASS Lee {

Public static void main (string args []) {

System.out.println ("Java Is Very Easy !!!");

}

}

We added a line:

System.out.println ("Java Is Very Easy !!!");

Let's explain this line, I said before, SYSTEM may be the name of the class, in fact this is a package name! What is a package, say this, make a very image of metaphor: In order to facilitate management of these some electric classes, we will put almost the same function in a folder, this folder is better than It is a package, and we have to make the almost the same package into a class, put it into a folder, which is called the library! Their included relationship is this: library - (included) - package - (included) - class - (included) - method, the method here is what we said. (A object inside the program you will think of it as a person, this person will skill) like a picture:

Why do we know this class? It should be a "dead class" that JDK is available to us, which is what I said that there is no power-on class.

System.out.println

(); What it means is to use system

OUT below the package

Subclasses, OUT subclasses

Println method

. The role of this method is to write you

System.out.println

() Things inside parentheses print on the screen

. At this point, our special skills have been completely created. This person has a special skill, which is to print some text on the screen, I put system.out.println ("Java is very Easy !!!); Watch as an operation, after an operation, we use a ";" means this operation is over! Regarding when there is ";", when did it ";", I will understand more, I will not say more, I will no longer say it, the more you look down! " In the middle of the library, the middle of the package and class is used. Game open, it is better than used. Instead of the folder inside the previously played metaphor.

Java provides us with very rich classes to call, (this also reflects the object-oriented essence: It is our best to make a compilation code. We only learn how to organize others to make a good job for us. Class, we can also compose some code yourself, write it into a class. Next time we want to use the same function, don't reply again, call this class directly, save a lot of effort! In fact Object-oriented is how we are lazy to use someone else !! Or you can make a common thing, you can use it when you want to use it!) When you use it, when you use it, how can you know another class? ? These require us to check the API documentation of Java, and how many classes can you remember? What is the class? When we need, we will check the API document. Which package of these classes is in which package of these classes, which special skills he can use. Regarding the API document, let us use the documentation of these things, JDK1.4

http://java.sun.com/j2se/1.4.2/download.html can find this link box can be

J2SE V 1.4.2 Documentation, how to use the API document! I may say that it may not, in short, you download it down, study slowly!

I have said that you may have the library of these Java, the package, the class, the class is still unfamiliar, don't understand, let you give you an intuitive understanding: find the directory of your JDK installation, (said in the first chapter) There is a file of src.zip, this is the source code of JDK, you should have RAR, don't say no! No, I don't care, how do you to install you?

Anti-button Click this file, select "Release to Here ..." in the pop-up menu. "You will find more folders in the installation directory, have you entered Java --- LANG see SYSTEM.JAVA? Here you will ask, why we only write

System.out.Println () does not provide information on Java and Lang! In fact, the answer is very simple, because Java.lang is too common, so don't write, Java will reference the things inside Java.lang by default, just like the first PATH environment variable, don't tell the compiler, compile I will go to the / java / lang directory to find SYSTEM.

Ok, the first program we have explained in detail, you should have a preliminary understanding of Java. And it is not as complicated to object-oriented. Next time we will contact it a little more, it is also a more boring grammar problem!

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

New Post(0)