Xiaokang will accompany you to learn JAVA -------- simple JAVA program, java -------- java

Source: Internet
Author: User
Tags ultraedit

Xiaokang will accompany you to learn JAVA -------- simple JAVA program, java -------- java

Analyzes a simple and complete JAVA program

 

Example: TestJava2_1.java

01 // TestJava2_1.java, a simple example of java

02 public class TestJava2_1

03 {

04 public static void main (String args [])

05 {

06 int num; // declare an integer variable num

07 num = 3; // assign an integer variable to 3

08 // output string. Connect the variable with "+"

09 System. out. println ("this is a number" + num );

10 System. out. println ("I have" + num + "book! ");

11}

12}

 

Output result:

This is number 3

I have 3 books!

 

 

Program description:

1. 1st comments of behavior programs. Java Comments start with the "//" sign. Comments help to read and detect programs, the commented content will not be executed during compilation.

2. The public and class in row 2nd public class TestJava2_1 are the keywords of Java, and the class is the meaning of "class", followed by the class name, and named TestJava2_1 in this program. Public indicates that the class is public, that is, it can be accessed throughout the program. Note that if a class is declared as public, the file name must be the same as the class name. In this example, the file name is TestJava2_1.java, the public class is followed by TestJava2_1. That is to say, in a Java file, there can be only one public class at most; otherwise, the. java file cannot be named.

3. Line 3 public static void main (String args []) indicates the starting point for running the program. 4th ~ 10-row functions are similar to functions in general programming languages, but they are called methods in Java ). Therefore, the main () function (main function) in C language is called main () method (main method) in Java ).

4. The body of the main () method ranges from the left braces "{" in the row 5th to the right braces "}" in the row 11th. Every independent Java program must have the main () method to run, because it is the starting point for the program to start running.

5. The 6th line "int num;" is used to declare num as an integer variable. Before using a variable, you must declare its type.

6. Row 7th "num = 3;" is a value assignment statement that assigns integer 2 to the variable num that stores integers.

Rows 7 and 8th are:

System. out. println ("this is a number" + num );

When the program is running, the content contained in the quotation marks (") will be output on the display. This includes "this is a number" and the value of the integer variable num.

8. System. out refers to the standard output, which is usually related to computer interface devices, such as printers and monitors. The subsequent println is composed of print and line, meaning that the content in the brackets is printed on the monitor, the standard output device. Therefore, after the statement of the first row is executed, a line break is generated, that is, the cursor is moved to the beginning of the next row to continue the output. You can change System. out. println () to System. out. print () to see the difference between line feed and non-line feed.

9. The Right braces in the 10th rows tell the compiler that the main () method ends here.

10. The right braces of rows 11th tell the Compiler class TestJava2_1 to end here.


What software should I install when learning JAVA?

I wrote the code for one night. I checked the information on the Internet and saw your problem. I listened to my suggestions and hoped to help you. We were all on the road.

MyEclipse is very powerful, my advice is not to use, development tools from notepad -- UltraEdit-32 -- JBuilder -- MyEclipse a little transition

Java beginners generally start with application development in the console (I like to write code in notepad at the beginning). For debugging in cmd, you must first build a development environment for your computer, you need to download a JDK on the sun website (which is also available on other download sites). After the installation is complete, you can start to write your first java program.
After using notepad to write a paragraph, you will find that this TM is too boring. If the program development is just like this, it will take a long time to earn money, it is better to move bricks and take water to the ground. (in this case, it doesn't mean that notepad is not good. The best choice for programmers is notepad. As a beginner, this is the only way to go ), at this time, you have to consider changing it. UltraEdit and JBuilder are all quite useful.

As you learn more and more deeply, you will not only be limited to console development, but will gradually become interested in web development (such as the online banking that you often use, now the online banking and trading systems of banks are all written in jsp (core j2ee technology). At this time, you need more powerful software to support your development (you go out to fight, how to beat the guy with a stick will not die. At this time, you have to consider Tool Change. development tools are just a tool you use to achieve your goal)

For web development, many people like to use Dreamweaver to design pages and drag them to Eclipse before developing business logic and other functions. Sometimes it is a mess, my suggestion is that you 'd better not use this item. You can write it manually to control it yourself.

When writing a Web page, you need to deploy it on the server software to dynamically display it in front of your eyes. At this time, you need a server software, currently, server tools such as tomcat are free of charge. You can download them online. I am not afraid to stick to the link, or Baidu may block my answers.

For java Development, if web development is involved,. JSP B. basic webpage design c. javaScript script d. server technology e. database f. you have to read more books, videos, and online materials. This will be of great help to you. You must write more!

It is difficult to get started with Java, but as long as you work hard, it will become easier to learn ,. NET is easy to use, but the more you learn, the language is the same. When you can easily learn other languages in java one day, you will be faster than others.

Tiandao rewards!

Come on, friend

After learning java, I can understand the program in the book. I can also write a simple program. What should a common JAVA programmer do?

You already have a certain degree of foundation, but you must read books such as jsp servlet and databases. You must understand mainstream DB systems such as oracle and SQL server, now you just learned the basic knowledge, and there is still a gap in the application phase. Now java is mainly used for commercial large-scale web applications, such as enterprise management systems, therefore, jsp servlet is required. In addition, we need to look at the popular open-source frameworks, such as struts. in short, you still have a lot to learn and it is not easy. make a good effort. As for the research, this is not a must, as long as you have the real skills.

As for J2EE, this can be understood by General programmers without having to learn deeply. After all, there are many other good solutions. It is generally used in large enterprise-level projects.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.