Review the third day of self-study Java notes (Java Language Basics)

Keywords: Java Programming Attribute


Day 3


	About identifiers in the java language
	1.What is an identifier?
	--In a java source program, any word that a programmer has the right to name himself or herself is an identifier.
	-- What elements can an identifier represent?
		* Class name
		* Method Name
		* Variable Name
		* Interface name
		* Constant name
		. . . . 
	2.Naming rules for identifiers?[Compiler will error if this rule is not followed]
		*A legitimate identifier can only consist of numbers, letters, underscores, dollar symbols and cannot contain other symbols.
		*Cannot start with a number
		*Strict case sensitivity
		*Keyword cannot be an identifier
		*There is no theoretical length limit, but it is best not to be too long
	3.Naming Specification for Identifiers [is only a specification, not a grammar, compilers that do not follow the specification will not error]
	*Best Witness
	*Follow hump naming
	*Class name, interface name: first letter uppercase, followed by each word first letter uppercase.
	*Variable name, method name: the first letter is lowercase, followed by each word in uppercase.
	*Constant name: all uppercase.
public class IdentifierTest01{//IdentifierTest01 is a class name whose name can be modified
	//main is a method name
	public statis void main (string[] args){//args is a variable name

	About literal values
	Literal value:
		-- 10,100
		-- true,false
	Literal values are data.Literal values are part of the java source program.Both identifiers and keywords are part of the java source program.
	Data is categorized in the real world, so there are also types of data in computer programming languages: [Data type]
		--10,100			Is an integer literal value
		--3.14					Is a floating-point literal value
		--true,false		Is a Boolean literal value
		--"abc","Chinese "belongs to string literal value"
		--'A','Person'is a character literal value
		*Be careful:
		java All string literal values in a language must be enclosed in double quotes, which are half-angled
		JAVA In languages, when all character literal values must be enclosed in single quotes, the single quotes are half-angled
public class ConsTest01{
	public statis void main (string[] args){
		System.out.println("Chinese Niubi");
		//Compilation error, because only a single character can be stored in single quotation marks, it is a character literal value
		//100 is a literal value, a positive attribute value, so since the data is stored in memory, it must take up a certain amount of memory space
	Variables about the java language
		1. What is a variable?
			* Variables are essentially a piece of memory, which has data types, names, and literal values.
			* Variables have three parts: data type, name, literal value [data]
			*Variables are the most basic unit of memory for storing data.
		2. What is the function of data types?
			*Different types of data have different types, different types of data allocate different sizes of space at the bottom
			*Data type is how much memory space the guide should allocate at run time
		3. Variable requirements: the specific data stored in the variable must always be consistent with the variable's "data type". Compile errors when inconsistencies occur
		4. Syntax Format for Declaring Variables
			Data type variable name
				*Data type:
					I haven't studied yet.
				*Variable name:
					As long as it is a legitimate identifier, the specification requires that the first letter be lowercase and the first letter of each subsequent word be capitalized.
					For example:
					int i;
					int age;
					int length;
					int num'
					Where int is the data type, i, age, length, num is the variable name
		5. How to assign values after variable declaration?
			Grammar Format:
				Variable name = literal value;
			Requirements: Literal values must have the same data type as variables.
			*The equal sign is an operator, called an assignment operator.The assignment operator first evaluates the expression to the right of the equal sign, and the result after the expression is executed is assigned to the left variable.
		6. Declarations and assignments can be done together.
			int i = 10;
		7. After the variable is copied, it can be assigned repeatedly and the value of the variable can be changed.
			int i = 10;
			i = 20;
			i = 30;
		8. With the concept of variable, memory space is reused.
			int i = 10;
		9. There are two ways to access a variable:
			*First: Read the specific data saved in the variable get
			*Second: Modify the specific data set settings saved in the variable
		10. Variables can declare more than one on a single line
					int a,b,c;
		11. Variables in java must be declared and assigned before they can be accessed

Look at the big man, what's wrong and bring it up in time, your little brother learns lessons immediately!!!!!!

Posted by on Sat, 31 Aug 2019 19:03:03 -0700