Java basic learning

Posted by pumaf1 on Thu, 10 Feb 2022 07:05:45 +0100

one, Composition of computer

A complete computer system includes two parts: hardware system and software system.

1. Hardware

  1. Controller (English Name: controller): refers to the master command device that changes the wiring of the main circuit or control circuit and changes the resistance value in the circuit to control the start, speed regulation, braking and reverse of the motor according to the predetermined sequence. It is composed of program counter, instruction register, instruction decoder, timing generator and operation controller. It is the "decision-making body" to issue commands, that is, to coordinate and command the operation of the whole computer system.
 CPU
     Central processing unit  ---Computer brain
     controller  --Processing instruction
     Arithmetic unit  --calculation
  1. Arithmetic unit: arithmetic unit, a part of a computer that performs various arithmetic and logical operations. The basic operations of the arithmetic unit include addition, subtraction, multiplication and division, logical operations such as and, or, non and XOR, and operations such as shift, comparison and transmission, also known as arithmetic logic unit (ALU).
  2. Memory: a collection of many storage units, arranged in the order of unit numbers. Each unit is composed of several binary bits to represent the value stored in the storage unit. This structure is very similar to the structure of array, so in VHDL language, the memory is usually described by array.
Storage unit:
         bit(Bit)            b
	     byte B(Bytes)       1B=8b
	     kB                  1kb=1024B
	     MB                  1MB=1024kb
	     GB
	     TB
  1. Input device: a device that inputs data and information to a computer. It is a bridge between computer and user or other equipment. Input device is one of the main devices for information exchange between users and computer system. Keyboard, mouse, camera, scanner, light pen, handwriting input board, joystick, voice input device, etc. all belong to input devices. Input device is a device for human or external interaction with the computer, which is used to input the original data and the program processing these numbers into the computer. The computer can receive all kinds of data, either numerical data or non numerical data, such as graphics, images and sounds, which can be input into the computer through different types of input devices for storage, processing and output.
  2. Output Device is the terminal device of computer hardware system, which is used to receive the output display, printing, sound of computer data, control the operation of peripheral devices, etc. It also displays various calculation result data or information in the form of numbers, characters, images, sounds and so on. Common output devices include display, printer, plotter, image output system, voice output system, magnetic recording equipment, etc.
  3. Others: GPU sound card network card motherboard
 Each hardware cooperates to complete certain tasks:
	1,On / off: data required by the operating system  --  Memory 
	2,Input data: input device--controller--Memory--Calculator--Memory--Output device/External storage

2. Software

Computer software is divided into system software and application software. If the computer is compared to a person, then the hardware represents the human body. Software represents people's thought and soul. A computer without any software installed is called "bare metal".
  1. systems software:
    System software refers to the system that controls and coordinates the computer and external equipment, and supports the development of application software. System software refers to the system that controls and coordinates the computer and external equipment and supports the development and operation of application software. It is a collection of various programs without user intervention. Its main function is to adjust, monitor and maintain the computer system; Responsible for managing various independent hardware in the computer system so that they can work together. System software enables computer users and other software to treat the computer as a whole without considering how each hardware at the bottom works.

     The relative path starts from the current path
     The absolute path starts from the drive letter root directory
     
     General: 1. Case insensitive
            2,Tab Key completion, switching between multiple subdirectories
            3,The up key and down key can switch between used commands
            4,cls Clear screen
     DOS:
     		Common instructions: ipconfig
     		Switch directory  cd(change dir)
     		Switch to subdirectory  cd Subdirectory name
     		Return to parent directory cd..
     		Switch drive letter:
     		The relative path starts from the current path
     		The absolute path starts from the drive letter root directory
     		General:
     		      1,Case insensitive
     		      2,Tab Key completion, switching between multiple subdirectories
     		      3,The up key and down key can switch between used commands
     		      4,cls Clear screen
    
    1. Application software:
      Application software is corresponding to system software. It is a collection of various programming languages that users can use and application programs compiled in various programming languages. It is divided into application software package and user program. Application software package is a collection of programs designed to solve certain problems by using computer, which is mostly used by users.
      Application software is the part of software provided to meet the application needs of users in different fields and problems. It can broaden the application field of computer system and enlarge the function of hardware.
Software, program:
Procedures in life:A set of ordered actions that are performed to solve a problem.
Program in a computer: a set of ordered instructions written in order for the computer to help us solve a problem.

2, Programming language - Java

programing language
1,Machine language: 010100100
            The readability is not strong, the maintainability and expansibility are not strong, and the speed is very fast
2,Assembly language: expressed by mnemonics add 2,3 result
   Assembler: increased readability. It is close to machine language, and the assembler is very lengthy. Fast speed, very familiar with the hardware composition of the computer
3,high-level language: C language–Ancestor result=2+3;
            Readability, maintainability and expansibility are good, but the speed is slow.
            Example: Java C# C++ Python javascript, etc.
4,Explanatory language: source program–The interpreter executes line by line Python,javascript
5,Compiled language: source program–The whole compiler is compiled into an executable file and then executed Java C#	java, high-level language, object-oriented

1. Java development history (belonging to Sun company)

In January 1996, Sun released the first Java development kit (JDK 1.0).
On December 8, 1998, the enterprise version J2EE of the second generation Java platform was released:
JavaME Mini Edition is used in mobile, wireless and limited resource environments.
JavaSE Standard Edition is applied to desktop environment - core.
Java EE Enterprise Edition, applied to Java based application server.
September 30, 2004 1.5 includes generic support, automatic boxing of basic types, improved loops, enumeration types, formatted I/O and variable parameters.
In 2009, Oracle announced the acquisition of Sun.
In 2014, Oracle released the official version of Java 8 -- lambda expressions and so on.

2. java Naming:

     java logo: A cup of steaming coffee
  1. java is as popular as this kind of coffee
  2. Software development can be programmed while drinking coffee
     java Father of: Java One of the founders: James·Gosling

3. java programming software installation

(java language-Cross platform–Cross operating system)
 jdk(java development kit)java Development package -----Help programming
 jre(java runtime environment)java Runtime environment - help run
 jvm(java virtual machine)java virtual machine ----java Language cross platform
  1. Download installation package
 with jdk8 take as an example

Search jdk8 in the browser or open the following website in the browser, find the required version in the position shown in the figure, and click download and install.

https://www.oracle.com/cn/java/technologies/javase/javase-jdk8-downloads.html

  1. Build environment
Configure environment variables: to make them available in any path bin Command under

(1) Add the jdk installation directory \ bin to the path in the system variable

D:\install\Jdk\jdk1.8\bin

(2) Or create a new JAVA_HOME jdk installation directory

D:\install\Jdk\jdk1.8

Post path append

%JAVA_HOME%\bin

classpath: no configuration required
Restart cmd and test javac -version

  1. Write the source program and create a new one java text file, as shown in the following figure:
public class Hello{
	public static void main(String[] args){
		System.out.println("hello,java");
	}
}
1,main Method is the entrance of the program, which has four elements, public  static   void  String[]
2,System.out.println("hello,java"); Output content to the console,; Indicates the end of the instruction
3,The file name should be the same as public The modified class names are consistent
4,Indent between levels, tab
5,Initial{At the end of the line, it ends}Align with this hierarchy
6,java Case sensitive
7,Class names follow the big hump method: each word has a larger initial  StudentManager
8,To enter in English
  1. Appears after compilation class bytecode file, as shown in the following figure:

    Enter the directory of the source program first
    javac file name java
  2. function
    java file name

3, Exercise:

         Welcome to the electronic system of industrial and Commercial Bank of China
               1,register
               2,Sign in
               3,sign out
    Please select:
public class Hi{
   public static void main(String[] args){
       System.out.println("\t Welcome to the electronic system of industrial and Commercial Bank of China\n\t\t1,register\n\t\t2,Sign in\n\t\t3,sign out\n Please select:");
   }
}

Note: explain the code and show it to the programmer, jvm Whatever,
The number of comments does not affect the efficiency of the program
 It is suggested to write notes, the more the better
1,Single-Line Comments  //
2,multiline comment  /*   */
3,Documentation Comments   /**   */     javadoc
 Question? Output Chinese garbled code
 Root cause: different coding formats occupy different space
 English letters, numbers and symbols: ascii code
iso-8859-1:Only English is supported. One character takes up one byte
unicode: 1 Characters occupy 2 bytes
utf-8:1 Bytes, 2 bytes, 3 bytes, 4 bytes
gbk,gb2312: Chinese is supported. One character takes up 2 bytes

Change the code to ANSI as follows: