Nezha’s life creed: If you like what you learn, there will be strong motivation to support it.

Take your front end hold to death, every day to learn cool cool, wechat search [programmer Doraemon] pay attention to this different programmer, if you learn things in love will have A strong power support.

Thank you for every programmer who loves the front end, no matter how strange the front end skills are, welcome to pay attention to add me to the group

preface

I hope I can get help for you through this article. (Thanks for one button three times)

Memory analysis, underlying algorithms, JDK source code analysis (IDEA version and JDK13)

Primary Learning Direction: Introduction to Java, USE of IDEA development environment (IDEA, Eclipse), object-oriented foundation and object-oriented design, Java VIRTUAL machine memory mechanism, memory analysis comprehensive understanding of object-oriented, memory analysis comprehensive understanding of programming language, object-oriented in-depth, array and data storage, exception mechanism and visual bug tracking, Common classes and JDK underlying source code analysis, the use of containers, IO stream technology, network programming, multithreading and concurrent programming, functional programming.

Programmer career development: Technical director, senior coder, architect, project Manager, CEO, etc.

Common language: c, Java, python, c + +, c #, javascript, PHP, swift, kotlin, etc.

Master: code ability, object-oriented analysis ability, memory and source code analysis habits, debugging and error checking ability.

Javase Java standard edition, ee enterprise development must learn.

The program is an expression of real logic, the essence of the program three elements, variables, if statement, loop statement. Considerations (variables), judgment conditions, infinities.

Table thinking to understand how databases store data

How do I understand classes and objects in Java? – Table idea

  • Table structure corresponds to: class
  • One row of data corresponds to: object

XML document: table structure corresponding to: document tag definition; A row of data corresponds to: the specified element.

Get to know the company: get to know the basics of the company, focus on which technologies, and research the company’s products.

javaversion

  • JavaSE(Java Standard Edition)Standard edition, targeted for use on personal computers.
  • JavaEE(Java Enterprise Edition): Enterprise edition, targeted at server-side applications.

Java features and advantages

The running mechanism of Java programs

The main types of high-level computer languages are compiled and interpreted, while the Java language is a combination of the two types.

Java first use text editor to write Java source program, source file suffix named. Java; Use the compiler (JavAC) to compile the source program into bytecode files, bytecode files suffix named. Class; Finally, the virtual machine (interpreter, Java) is used to interpret the execution.

I drew a picture:

JVM, JRE, and JDK

The JVM (Java Virtual Machine) is a Virtual “Virtual Machine” that executes bytecode. It contains: instruction set, register set, structure stack, garbage collection heap, memory area. The JVM is responsible for Java bytecode interpretation running, and it runs as it interprets, so speed is somewhat affected.

Different operating systems have different virtual machines. The Java VIRTUAL machine mechanism shields the differences between underlying operating platforms and implements “compile once, run anywhere”. The Java virtual machine is the core mechanism for cross-platform implementation.

I drew a picture:

Java Development Kit (JDK) contains: JRE virtual machine, library functions, and files necessary to run Java applications.

The Java Runtime Environment(JRE) contains the Java VIRTUAL machine (VM), library functions, and files required to run Java applications.

The JVM (Java Virtual Machine) is a Virtual “Virtual Machine” that executes bytecode.

The relationship between JDK, JRE, and JVM is shown below:

If you just run a Java program, all you need is a JRE, which is usually very small and includes the JVM; If you want to develop Java programs, you need to install the JDK.

JDK download and installation

Download address

Now the new:

Click Accept License Agreement, select the corresponding version, and download it

Go to the JDK installation directory

  • binDirectories store executable binary files
  • libStore relatedjarpackage
  • src.zipisJDKrelatedJAVAClass source code

Configuration of the environment variable Path

C: \ Program Files \ Java \ JDK - 15.0.1

Right click computer, Properties, Advanced System Settings

It must be an English semicolon and not a Chinese semicolon

Test JDK installation successfully

The first oneJavaThe program

Develop your first Java program using Notepad

public class helloWorld{ public static void main(String[] args){ System.out.println("Hello Java! Author of Nezha "); }}Copy the code

Java file. Open a command line window, go to the directory where the Java file resides, and run javac helloWorld. Java to generate the class file.

Explain and run phase: Java helloWorld, run the helloWorld.class file generated by the compilation and output the results.

Common mistakes

  1. The javac command was not found because the path variable was incorrectly configured
  2. There may be a problem with the operating system display setting that hides the file extension
  3. Can’t find main method, it should be written incorrectly

Common DOS commands

  • cdDirectory path to a directory
  • cd ... To go to the parent directory
  • dirTo view the list of files and subdirectories in this directory
  • cls, clear screen command
  • TabKey, automatic completion command

Common Java development tools

  • Clipse official website

  • IntelliJ IDE

  • NetBeans official website

Download and install Eclipse

Download address

Choose Eclipse IDE for Java Developers, according to their own JDK installation, download complete, directly decompress. Go to the directory and double-click Eclipse.exe to use it.

A workspace is the directory where a Java project is stored, usually using the default workspace directory.

To create a Java Project in Eclipse, select New, Java Project and start creating a new Java Project.

Develop and run Java programs using Eclipse

Right-click in the SRC directory to create a Java class.

SRC and bin directories for Java projects

  • SRC is used to store source code
  • Bin Is used to store the generated class file

Pool game

ball.png

desk.jpg

import java.awt.*; import javax.swing.*; public class BallGame extends JFrame { Image ball = Toolkit.getDefaultToolkit().getImage("images/ball.png"); Image desk = Toolkit.getDefaultToolkit().getImage("images/desk.jpg"); double x=100; // Double y=100; Boolean right = true; Public void paint(Graphics g){system.out.println (" Windows are drawn once! "); ); g.drawImage(desk, 0, 0, null); g.drawImage(ball, (int)x, (int)y, null); if(right){ x = x + 10; }else{ x = x - 10; } if(x>856-40-30){//856 is the width of the window, 40 is the width of the table border, 30 is the diameter of the ball right = false; } if(x<40){//40 is the width of the table border right = true; } // Window loading void launchFrame(){setSize(856,500); SetLocation (50, 50); setVisible(true); // Repaint window 25 times per second while(true){repaint(); try{ Thread.sleep(40); //40ms, 1 second =1000 ms. }catch(Exception e){e.printStackTrace(); }}} public static void main(String[] args){system.out.println (" zha: Nezha "); BallGame game = new BallGame(); game.launchFrame(); }}Copy the code

Effect:

import java.awt.*; import javax.swing.*; public class BallGame2 extends JFrame { Image ball = Toolkit.getDefaultToolkit().getImage("images/ball.png"); Image desk = Toolkit.getDefaultToolkit().getImage("images/desk.jpg"); double x=100; // Double y=100; // Double degree = 3.14/3; / / radian. Public void paint(Graphics g){system.out.println (" Windows are drawn once! "){system.out.println (" Windows are drawn once! "); ); g.drawImage(desk, 0, 0, null); g.drawImage(ball,(int)x, (int)y, null); x = x+ 10*Math.cos(degree); y = y +10*Math.sin(degree); / / run into upper and lower boundary the if (y > 500-40-30 | | y < 40 + 40) {/ / 500 is window height; 40 is the border of the table, 30 is the diameter of the ball; Degree = -degree; } / / touching the border around the if (x < 40 | | x > 40-856-30) {degree = 3.14 degree; } // Window loading void launchFrame(){setSize(856,500); SetLocation (50, 50); setVisible(true); // Repaint window 25 times per second while(true){repaint(); try{ Thread.sleep(40); //40ms, 1 second =1000 ms. }catch(Exception e){e.printStackTrace(); }}} public static void main(String[] args){system.out.println (" zha: Nezha "); BallGame2 game = new BallGame2(); game.launchFrame(); }}Copy the code

The renderings are as follows:

Likes, favorites and comments

I’m Jeskson, thanks for your talent: likes, favorites and comments, and we’ll see you next time! ☞ Thank you for learning with me.

See you next time!

This article is constantly updated. You can search “Programmer Doraemon” on wechat to read it for the first time, and reply [information] there are materials of first-line big factories prepared by me, which have been included in this article www.dadaqianduan.cn/#/

Star: github.com/webVueBlog/…