Java Programming Learn Java from Scratch - Basics (1)

Note: This article is only for people who want to get started with zero foundation, college students, students who are about to graduate from related majors, and people who want to change careers but have not yet started.

1. Write in front

From entering the university to the current workplace, all kinds of experiences made me have such an idea. I want to use a platform like CSDN to provide some people who read my articles with an opportunity to understand whether they are suitable for this industry. Opportunity.
I don’t know if you who are reading my article have the same experience. The school curriculum is complicated and you are not serious, so that you can’t even complete the most basic homework. Or, during the study period, I was busy with various examinations and neglected professional courses, so that when graduation was approaching, I didn't understand the relevant knowledge. Or if you are interested in entering this industry, but you find that there are various online tutorials, and you don’t know where to start.
If you have encountered or are encountering such problems, I suggest you read my article. The article will be a series of continuous updates, accompanied by free supporting video explanations at station B. This whole set of articles and videos will be Start from scratch and lead you step by step to the world of java.
When you have finished all the articles and have the complete development ability from scratch, then think about whether you are suitable for this industry. At that time, you can choose to enter the industry, or you can choose to train and improve, no matter what you choose in the end , I only hope that you can take the initiative, it is up to you to decide whether to stay or not!

Second, know java

1. The origin of java
According to legend, the name of java comes from an island called Java in Indonesia. The island is rich in coffee and other substances, so the early icon of java is a cup of coffee.
The real origin can be found on Baidu Encyclopedia, which is only used as a personal guide.
2. Classification of
java Java is divided into javaSE, JavaEE and JavaME
JavaSE is the standard version of java classification, and it is the basic knowledge to be learned when new to java.
JavaEE is the enterprise version in the java classification, is the advanced level in java, and involves a wide range of knowledge.
M in JavaME is the abbreviation of Micro, which is used in embedded electronic devices.
3, jdk, jre and jvm
to learn java, first of all, we must figure out what jdk, jre and jvm are.
Why should we learn jdk, jvm and jre?
Have you ever had the same question during your study?
This is a very typical phenomenon in learning - failing to grasp the focus of learning. In fact, in the process of learning, especially the students who have just started, it is difficult to grasp the key knowledge and feel that everything is important, but after memorizing a lot of concepts, I found that I have memorized a historical background, so that in the later study You will wonder if you really need to memorize carefully, so that in the end you don't remember anything.
When learning a knowledge, we must first figure out why we need to learn this knowledge, instead of blindly memorizing it.
We learn java, and use this knowledge for programming. This is our purpose. Based on this purpose, we need to think about what we need. The first is the development environment, the running environment and the machine that runs the java program, and the second is the development knowledge, rules and so on. The jdk, jre, and jvm are the development environment of java, the running environment of java, and the machine that runs java programs.
Among them, jdk contains jre, and jre contains jvm.
Java code is portable, that is, it is developed once and used in multiple places, which depends entirely on the cross-platform characteristics of JVM.
4. Install jdk
When it comes to this, whether you are still confused, it doesn't matter. Next, I will take you to experience jdk, jre and jvm.
First of all, you need to go to the Internet to download a jdk, the version can be selected arbitrarily, I will choose the 1.7 or 1.8 version in the later teaching, it is recommended to choose one of them first. After the download is complete install the jdk on your computer.
The next step is to configure environment variables. Right-click [My Computer] [Properties] [Advanced System Settings] [Environment Variables]
insert image description here
insert image description here
to configure various tutorials on the network. If you encounter problems, you can leave a message for guidance.
Test method after successful installation:
Press and hold the win+R key on your computer keyboard, enter "CMD" in the pop-up box and press Enter, enter "java -version" in the pop-up black box, pay attention to the space in the middle, When the version of java you installed is displayed after entering it, enter "javac -version" again to see if it is still the version of your java. The rendering is as follows:
insert image description here
The java development environment is installed here. With the environment, you can continue to learn java and develop Havana programs.
As for why only one jdk is installed, here is the knowledge point above, jdk includes jre, and jre includes jvm.
The program written in Java is that we can read and understand English words, but due to the special structure of the computer, it can only recognize binary files. Therefore, we need a translator to communicate with the computer, that is, a virtual machine (javac compilation command).
The class file generated after Javac is compiled is the binary file that the computer can recognize.
This process involves two commands: javac compile, java run
Javac command: Check whether the java program has spelling and grammar errors
Java command: call jvm (java virtual machine) to run the program, the program does not allow logic errors.

Third, the first java program

After writing so much, let's do something fulfilling, write a java program and run it.

public class Hello{
    
    

   public static void  main(String [] args){
    
    
		System.out.println("java学习第一天!");
		fun2();//方法的调用
   }


   public static void fun1(){
    
    
		  System.out.println("我是方法1");
		  
   }
 
   public static void fun2(){
    
    
		  System.out.println("我是方法2");
		  
   }

   //所有方法的宿命:被调用的  
   //只有主方法有资格  被虚拟机内部程序调用;其他方法:被主方法调用 

  /*
  例如:三个方法 main主方法  fun1  fun2  :主方法main 可以 调用fun1或者fun2  
        fun1和fun2之间也可以互相调用
  */
}

Create a new txt file in a certain drive letter, copy the above code into it, save and modify the file name to Hello.java, then call up the cmd window, first enter the drive letter where the java file is located, the D drive is d:, f The disk is f:
compile and run the file in sequence, the compilation is javac, and the operation is java, as shown in the figure:
insert image description here
The first stage ends here, and the articles will be updated in the later period. I hope this article is useful to you, and you can communicate and learn together in the comment area below. , I will attach the address here after the video of station B is updated, thank you for your support!

Guess you like

Origin blog.csdn.net/fzt12138/article/details/122084009