Three hundred lines of Java per day (01-02 days, environment construction and basic syntax)

Three hundred lines of Java per day (01-02 days, environment construction and basic syntax)

Note: here are the synchronous notes and records of JAVA self-study and understanding. If you have any questions, please correct them

@[TOC] (article directory)

preface

At the undergraduate stage, I have never been in contact with java, so the language itself starts from 0, but I have been in contact with C, C + +, Python and other languages before, and I have some thinking of computer languages.
This blog is a record for standardizing self-learning, but it can also be used as a reference tool for subsequent Corrigendum while encouraging self-learning.

1, Day1: environment construction and eclipse installation (the beginning of everything)

Basic online operation instructions for environment construction and installation( Environment construction and Eclipse installation tutorial )It can be completed soon. After setting the path correctly, enter the command in cmd:

java -version

To verify our construction results:

eclipse installation will not be repeated here
What kind of software is this? Eclipse is an open source and Java based extensible development platform. In itself, it is just a framework and a set of services for building a development environment through plug-in components. Eclipse comes with a standard set of plug-ins, including the Java Development Kit (JDK).
After setting up the environment, you might as well learn the common first step convention of any language once:

package basic;

public class HelloWorld {
	
	public static void main(String[] args) {
		System.out.println("Hello, World !");
	}//of main
}//of class HelloWorld

Normal display available:

At this point, the road of learning is officially opened!

2, Day2: basic addition, subtraction, multiplication and division and the middle order of println

The code is as follows:

package basic;

public class BasicOperations {

	public static void main(String args[]) {
		int tempFirstInt, tempSecondInt, tempResultInt;
		double tempFirstDouble, tempSecondDouble, tempResultDouble;

		tempFirstInt = 15;
		tempSecondInt = 4;

		tempFirstDouble = 1.2;
		tempSecondDouble = 3.5;

		// Addition
		tempResultInt = tempFirstInt + tempSecondInt;
		tempResultDouble = tempFirstDouble + tempSecondDouble;

		System.out.println("" + tempFirstInt + " + " + tempSecondInt + " = " + tempResultInt);
		System.out.println("" + tempFirstDouble + " + " + tempSecondDouble + " = " + tempResultDouble);

		// Subtraction
		tempResultInt = tempFirstInt - tempSecondInt;
		tempResultDouble = tempFirstDouble - tempSecondDouble;

		System.out.println("" + tempFirstInt + " - " + tempSecondInt + " = " + tempResultInt);
		System.out.println("" + tempFirstDouble + " - " + tempSecondDouble + " = " + tempResultDouble);

		// Multiplication
		tempResultInt = tempFirstInt * tempSecondInt;
		tempResultDouble = tempFirstDouble * tempSecondDouble;

		System.out.println("" + tempFirstInt + " * " + tempSecondInt + " = " + tempResultInt);
		System.out.println("" + tempFirstDouble + " * " + tempSecondDouble + " = " + tempResultDouble);

		// Division
		tempResultInt = tempFirstInt / tempSecondInt;
		tempResultDouble = tempFirstDouble / tempSecondDouble;

		System.out.println("" + tempFirstInt + " / " + tempSecondInt + " = " + tempResultInt);
		System.out.println("" + tempFirstDouble + " / " + tempSecondDouble + " = " + tempResultDouble);

		// Modulus
		tempResultInt = tempFirstInt % tempSecondInt;

		System.out.println("" + tempFirstInt + " % " + tempSecondInt + " = " + tempResultInt);
	}// of main
}// of class BasicOperations.java

The normal display is as follows:

Day2 summary

The basic operation of java is consistent with the expression of many languages, so today's focus is to pay attention to the naming specification of variables, so as to determine a good foundation for later code writing.

·About variable naming:
java generally names the identifiers of methods and variables according to the lower camel case, while the identifiers of class names are generally written in the upper camel case. In addition, see the famous name. For example, there is a "double" identification description at the end of the double variable above.

·Other formats:
The code area is clearly divided into three parts: data declaration, data initialization and data operation, and each part is separated by a carriage return. At the same time, each function segment briefly describes the function with notes.

ยท Tips:
Source - > format in Eclipse can quickly format the code format

Keywords: Java Eclipse

Added by ares on Mon, 21 Feb 2022 18:59:41 +0200