Java Grammar Manual III (Object Oriented)

Java Grammar Manual III (Object Oriented)

Java object-oriented programming:

Procedural or Object Oriented

Both are ideas, and object-oriented is relative to process-oriented.

  • Process-oriented, emphasizing functional behavior, with functions as the smallest unit, consider how to do it.
  • Object-oriented
    Encapsulate functionality into objects, emphasize functionally enabled objects, take class/object as the smallest unit, and consider who does it.
    Object-oriented emphasizes more on the use of human thinking methods and principles in daily thinking logic, such as abstraction, classification, inheritance, aggregation, polymorphism, and so on.

Three main object-oriented features:

  • Encapsulate Inheritance Polymorphism

Classes and Objects


  • Classes are descriptions of a class of things, and abstract concepts are types of objects.People can be interpreted as a class;
  • An instance of a class is the characteristic (attribute) behavior (method) of the class that the object will have;
  • Attributes of the class:
    The static characteristics that an object possesses, called the properties of a class: all humans have: name, height, weight...
  • Class behavior:
    The dynamic characteristics of the operations performed by an object are called the methods of classes: people can eat and sing..


  • Procedure: The object is the individual of a certain kind of thing that actually exists, so it is also an entity of the objective thing.Xiao Ming, Xiao Hong is the object of human beings
  • Objects have: static/dynamic characteristics, called the object's attribute/behavior method;Create new from class instantiation

Relationships between classes and objects:

  • Class is an abstract concept of objects with the same behavioral characteristics, while object is an individual that exists in fact in the abstract concept of class
  • The relationship between classes and objects is like a tool and a model:
    Many of the same models can be made from one touch tool.But the color behind it...can also be changed to represent different objects...
  • Conclusion:
    Classes are abstract objects and objects are instances of classes.
    Class is the type of object;

JAVA is an object-oriented language:

Class declarations for Java:

Classes in Java simulate concepts from the real world into computers
Create a class in Java to use: class, a class name, a pair of braces {};

Attributes of the class:

Define variables in the class body to describe the static characteristics (attributes) of a class. These variables are called class member variables.Variables in a method are called local variables

Methods for writing classes:

Defining a method in a class describes the behavior of the class (its member methods)
Define method syntax:

1.Method Name 2.Method Return Value Type 3.Method body		
Access modifier return value type method name(){
	//Method body:
	//Code to run the operation

Access modifier: 	//The public... access modifier limits the scope of accessing this method
 return type: 	//The type of result returned after method execution (base type/reference type), or void without return value;Must be filled in!
Method Name: 		//A meaningful name for easy invocation 
			//Note: Naming conventions (Camel nomenclature, lowercase first character, capitalization of other words) 

Be careful: 
	//Method body in curly braces {} Method body is a piece of program code that does some work
	//Method names are used primarily when calling this placement, and camel naming is commonly used in java
	//The method may return a result after execution. The type of the result is called the return value type, and the return value is used. 
	//If the method does not return a result, the return value type defaults to void; (No return value type)
	//Return effect: 1. Jump out of method 2. If the method has a return value this value is placed after return; (Return a value to the method)   
	//Return expression;Returns a value (expression) to the method;The expression type should be the same as the return value type of the method.

Using classes/creating objects:

The purpose of a class is to create objects,Generate objects from classes,A process called instantiation of a class
 An instance is an object
 A class can generate multiple objects

	Class Name Object Name = new Class name();  
	//new to create objects;
	//Use Objects. Call Properties/Methods

	Object Name.attribute			//Reference Object Properties 
	Object Name.Method Name();		//Reference Object Method		
	//Operation by object name'..	

Use Object .Point Call Class Properties
 If the class attribute does not assign an object.Call property to its default value of variable type!!
int			0
String		null
char		'\u0000'	
boolean		false
double		0.0
...			...

Naming Specification: 
	camel(Camel)Nomenclature: 		Capitalize the first letter of a word after the first letter is lowercase; 		eg: showCenter userName.... (Define Properties/Method)
	Pascal(Pascal)Nomenclature: 	Capitalize the first letter of each word;				eg: School...				(Define Class)

Anonymous classes:

Anonymous classes are one of the internal classes... not used much in actual development, but the source code may be visible!

Anonymous object:
	// Simply understand that a class declares objects to invoke properties and methods in a class.Perform operations;
	// Anonymous objects are simply no objects: new class (). properties / methods ();  
	// There is no operation to create an object that calls a class's method/property;
	// Rarely used, benefits run out of auto-reclaimed memory space~
	Use scenarios: Multithreaded...
Anonymous subclass:
	// Java has inheritance, and subclasses inherit the parent class.
	// Anonymous subclasses, like anonymous objects, are usually recycled after only one use.
	// Assumption: abstract class A {//abstract class A};    
	// That is, A = new A() {// overrides class A Abstract methods, indirectly inherits class A properties/methods, or can customize specific properties/methods of this class (for internal access)};An abstract class cannot be a new instance, that is, it represents an anonymous class.
	// An instance of this anonymous class is created with object a, which is a borrowed parent class name without a name and can be invoked: {Properties/Methods in} and non-abstract public methods/properties of the parent class can also be invoked; (Almost the same as ordinary classes)  
	// Although anonymous classes can customize methods/attributes, their object receive type is inherited class parent/implementation class.So there's still no access (type conversion required), but because you're anonymous ("cool")... only private internal access can be set;
Anonymous implementation class:
	// Similar to anonymous subclasses;
	// Assume there is an interface: interface A{} that is, A = new A() {....}; 

Object-oriented benefits:

//Consistent with human thinking habits
//Information hiding to improve the maintainability and security of the program;  
//Encapsulation implements modularization and information hiding as attributes/methods (behaviors) of classes Encapsulation ensures that modifications to them will not affect the interests and maintenance of other objects
//Encapsulation improves security by preventing arbitrary access to object properties/methods outside the object to avoid the impact of external errors 
//Enhances program reusability A class can create multiple object instances to increase reusability

Class parameterless methods

Defining a method in a class describes the behavior of the class (its member methods)

Define method syntax:

1.Method Name 2.Method Return Value Type 3.Method body	

Access modifier return value type method name(){
	//Method body:
	//Code to run the operation
Access modifier: 	//The public... access modifier limits the scope of accessing this method
 return type: 	//The type of result returned after method execution (base type/reference type) can also have no return value void;
Method Name: 		//A meaningful name makes it easy to call attention to: naming conventions (camel nomenclature) 

Member variables and local variables:

Classes can be defined as variables/methods (members)
Variables (local) can also be defined in class methods

Member variables:
	Variables defined in classes,Has access modifiers

local variable:
	Its scope is mainly defined in the method/{ } So only in the defined method/{ }Use,So there are no access modifiers;
Be careful:
	Scopes are different:
		Local variable scope is limited to the method by which it is defined;
		The member variable scope is visible throughout the class All member methods can be used if the access modifier allows them to also be used outside the class;
	Initial values are different:
		Member variable if it is not initialized in the class definition java It will be given a default initial value;
		Local variables are not assigned by default if they are not assigned by the system so they must be defined before they can be used;
	Local variables in the same method cannot have the same name. Different methods can....;
	Local variable member variables can have the same method name and have a higher priority when used;  The procedure follows the proximity principle!

Method with parameters

Defining a method in a class describes the behavior of the class (its member methods)

1.Method Name 2.Method Return Value Type 3.Method body

Access modifier return value type method name(<parameter list>){
	//Method body:
	//Code to run the operation
Access modifier: 	//The public... access modifier limits the scope of accessing this method
 return type: 	//The type of result returned after method execution (base type/reference type) can also have no return value void;
Method Name: 		//A meaningful name makes it easy to call attention to: naming conventions (camel nomenclature) 

parameter list:	//Method () Place parameter types in parentheses to specify the variables/data to be used to operate within the method;They are also divided into formal parameters.
			Formal parameters: Occurs at method definition time,In parentheses, only used in the current method (Local variables take up stack space method is automatically reclaimed at the end),Internal operation execution for methods;
			Arguments: When a method is called, the value of the argument is passed to the parameter so that it performs operations within the method, so the argument is not affected when the method is called; 

//Note: Arguments are value types/reference types: value types are passed to parameter values, and arguments are unaffected.Reference type pass-through address arguments are affected (String special);


The method is, Defined in Class, Is a behavioral operation. main Another way;

When invoked, other methods can be invoked inside the method (You can call yourself, of course: recursion,Note that there are return/End;Otherwise, the dead cycle will go wrong)

The same class can be called from one another, different classes declare object calls (Notice the access modifier...)


Classes and Objects

Class Object is the two core concepts of Object-oriented

  • Class: A class is an abstract conceptual definition of a description of a type of transaction
  • Object: An object is an individual of a specific thing that actually exists

Construction method

Constructors, some people call them construction methods... All in all, one thing..

  • We all know to use the properties and methods of classes to accomplish program functions. The first task is to instantiate the class object name = new class ();
  • Suppose the method of creating class instances, ww, is called a constructor.
  • The constructor of a class is a special method of the class.


1.Method name is the same as class name return value	
3.Generally speaking, it mainly completes the initialization of the object 
4.The construction method may Private (encapsulation) //However, other classes cannot initialize this class, so ~ (singleton instance specific ~) is not recommended;
5.Construction methods can be overloaded,One can be declared depending on the parameter/Multiple Constructors; (Whether a class must have a constructor,No system will provide a parameterless construction method by default, otherwise use the definition!)
	Be careful: Constructor does not return a value,It doesn't mean you can void  void Indicates that the return value type is empty, not that there is no return value so No, it can't be void  ※
	(If JAVA Constructor added in void The return value is not an error but a and constructor / A method with the same method name

Overload overLoad:

The same class can have the same: method name?A: Yes!-o - The drop is reasonable, but it does!

※ Characteristic: (Two identical but different)
1,Method Name Same  ^^    
2,Same Class(Or subclasses)!!  
3,Method (parameter list) is different!    
	//It's the parameters that make the difference!When using this method, the system also determines which method is called segment by the order of the type of method parameter you invoke.
	Normal methods actually transform everything,Just add a way to overload,A class can have the same method name;(Two identical but different). 
Be careful:
	Overload ,Same Class,Same method name ,List of different parameters,Called method overload return value/Access modifier??(And return value/Access modifier independent)
	// Variable number parameter method: that is, the parameter direction is an array JDK5.0 was previously a data representation so used simultaneously: Variable parameter type int / int array parameter will error; (Overload parameter type as int example)	

Access modifier return value type method name( data type...Variable Name ){
		//Data type... Variable name: Variable number of parameters, which means that when passed to a method, zero/more parameters of the same type can be passed in according to the corresponding data type.
		//When used internally in a method, the variable name [0] The first parameter variable name [1] The second parameter... is equivalent to a convenient array;
		//When used, this variable number of parameters is generally placed last and there can be one method; (Otherwise the editor doesn't distinguish ~)
		//Figure: Variable parameters;


Three Object-Oriented Features( Encapsulate Inheritance Polymorphism ) One of:
	// When we create a class object, we can assign values to it in the following ways:object.attribute;
	// However, if you want to restrict the value you assign, you need to write a judgment inside the method set.After that, we can assign values to objects. attributes, so we usually set them: private (private attributes)
	hidden object(class)attribute,And implementation details,Open interface only(Method);   Controls the reading of properties in programs get(read) And modifications set(write) Access level of;
	set(parameter){ ...... };  //Encapsulation assigns values to class object attributes by set ting them, but it can also be judged internally to assign only legal values: age cannot be negative;
	// It can also be a private method that is not exposed to the public, but allows internal calls;Singleton Test (Constructor Set Private Subsequent ~)...
	// Our pursuit of programming is: high cohesion (internal data manipulation details of classes are done by themselves, no external interference allowed) / low coupling (only a small number of methods are reserved for use outside); 
Encapsulated representations require permission modifiers to match representations:
	default(Write nothing by default!)

this in Java

// this can be understood as the current class object;You can call properties/methods/constructors;
// Call member variable to resolve: conflict between member variable and local variable with the same name;
// Constructor in class: (Fig. this constructor reduces code redundancy)
Be careful: this Reference of an object's internal value to itself,therefore this Only instance properties can be invoked/Method,Constructor (Static members cannot be invoked: static), this Can only be used in this way!! 


The concept of inheritance:

  • Inheritance allows us to define another class based on one class, making it easier to create and maintain applications, while helping to reuse code to reduce redundancy and save development time.
  • One class in Java can inherit from another;Classes that are inherited are called "parent"/ "base". Classes that inherit other classes are called "subclass"/ "derived class";
  • It is object-oriented and a very important feature of programming. Subclasses have not only unique members of their own classes, but also members of their parent classes.
  • Inheritance should conform to the relationship of is a;eg: truck is a car, truck is a car;
Inheritance Features:
	Transitivity of Inheritance :A inherit B class B inherit C  A Have C Class Properties/Method; B yes A Parent Class  C yes A Indirect parent;
	Single Root Inheritance :A subclass cannot inherit multiple classes at the same time,Only one class can be inherited;
	//All classes in java directly or indirectly inherit the Java.lang.Object class!
	Java Inheritance keywords: extends Realization java inherit A extends B (A Class Inheritance B class);
	super Represents a default reference to a parent object (Understandable is an instance object of the parent class) Therefore, the class properties of the parent class cannot be accessed/Method( static) 

 	Be careful:	java Subclass inherits parent property/Method (cannot inherit a constructor but can only be called) 
			By this Accessing parent class properties/Method (but not recommended) super Visit;   // Using this this will first look for attributes/methods in this class. If you drop yourself, no attributes/methods in the parent class will be found.
			Declaring constructors in subclasses requires the use of super(); Call the constructor of the corresponding parent class : super( Parameter Specifies Parent Constructor Parameter Matching );//The first line indicates (must!!)  
				The system calls the parent class parameterless constructor by default if the call is not displayed super(); !! Notice if the precondition parent has no arguments!! this(); Constructor of this class is not a parent!!
			this  and super Can only be used in this way!!And only two choices can be used;

	Access rights: High Level - low
		public (Public):	All accessible
		Default (do not write):	This class of packages is accessible
		protected(Protected):	This class is homozygous(Different packages are also available) Accessible
		private (Private):	Allow access to this class only
		// Can be used to modify classes and internal structures: classes, attributes, methods, constructors, internal classes
			attribute: Membership variables allow you to set access permissions;  // If access is unsuccessful: is not visible;error 


Subclass overrides parent method:  Method subclasses of subclasses that do not satisfy the parent can override their modifications/cover  (overriding)

	Method Name Same
	Parameter lists are the same
	Return values of the same type (Or its type subclass: parent method return value Object  The return value of the suboverride method can be String )		
	The overridden method access modifier has more permissions than the overridden method! (Subclass overrides parent class method access permissions must >= Parent Method)
	Subclass overrides parent method,Exception type thrown,Exception type cannot be greater than parent class; 

Be careful: 
	Child and parent method overrides: Method Name Same Parameter List Same... No relation to method overload!!;	
	Methods with the same name and parameter as the parent class are either non- static(Override) Either static (It's no longer a rewrite); If one is static One is not an error;	

JAVA Abstract classes and methods: (When Parent's Method,Must be overridden by subclasses,That parent method doesn't need a body,Can be defined as an abstract method,abstract class)
abstract class: 	Usually used to represent (Parent Class) Conceptual Classes eg: Animal/vehicle/Gas... 
therefore:	An abstract method has no body, And there must be abstract classes (but abstract classes can also have non-abstract methods)/Attribute construction methods..)
		Abstract classes cannot be instantiated either,So abstract classes,Typically, they are parent classes; But abstract classes are constructors,Facilitate instantiation of subclasses: super();

and:		Subclass (Non-abstract Class) The abstract method of the parent class (abstract class) must be implemented!; Subclass inherits abstract class,Its abstract method must be implemented; 
		therefore: No, it can't be private final // Conflicts with abstract class concepts, and the editor will error!		

Abstract method: Methods that need to be overridden by (non-abstract) subclasses,Therefore the access modifier cannot be private(Errors will occur),No, it can't be static(Not Override:And static You can use classes.Called while abstract method has no body) final(Do not allow overrides) Modification!!	  
Keyword:   abstract (abstract)
		 abstract class: public abstract class class{};   Abstract method:  public abstract void Method Name();  // Abstract methods have no method body ~and classes must be abstract classes/interfaces


denotation:"Multi-modality means unified operation,The same operation can be handled differently for different objects,Produce different execution results;
Advantage: Reduce the amount of code,Improving code scalability and maintainability

JAVA Implement Polymorphism:
	Parent Class ww = new Subclass();  Parent type can be declared new Subclass object,Call overridden methods ,Because different subclass objects override different method bodies, the output is based on new Different subclasses but different implementations of polymorphism;
	ww.Method();  //Implement operation
	Be careful: 
		Subclass to Parent Type Conversion: father o = new son;     (call: Convert Up)//Complete the polymorphic operation, depending on the subclass of the subclass override method new, the object. method will show different effects;Of course, the unique methods in subclasses are inaccessible to objects of the parent type!
		Parent to Child Type Conversion: son o = (son)new father; (call: Convert Down)//Strongly converting an object to its corresponding subclass type can cause errors when calling a method. The new parent is essentially a parent-type object that is strongly converted to a subclass (no error) but it is not a subclass!,Generally, this conversion is a combination: parent o = new child;Sub o1 = (sub)o; //Turn Strongly  

		Conversion type from low to high system will automatically/Implicit Conversion  eg: double = int; (call: Convert Up)
		Conversion type from high to low system requires manual/Display Conversion  	eg: int = (int)double; (call: Convert Down:Will lose accuracy)
		JAVA Strong Transition Failure System Error: ClassCastException error,Affect program operation, So it is recommended to use instanceof Convert after judgment~

		instanceof operator: Check if the object type belongs to this type!!
			A object instanceof Object(type); //true flase 
			instanceof When using, you must also conform to the subordinate relationship of the inheritance tree or compile errors!!	

Implement Polymorphic Conditions: 
	1.Existence of Inheritance
	2.Note that overrides exist: Overrides are methods,Not an attribute. Subclass and parent all have an attribute id; When called, your attributes and values are called based on your object type, And not because of you new Who decides! 
	3.Parent Reference Variables Point to Subclass Objects (Subclass to Parent Type Conversion) Parent Classes ww = new Subclass();
Polymorphism is a compile-time behavior,Or Runtime Behavior/according to new Different subclasses tune the same method to produce different results: Runtime;(Figure: Polymorphic Runtime Polymorphic Virtual Method Overload and Override)


What is an interface:
	In life: Interfaces are a set of specifications USB
	In software: It's also a set of specifications and standards,You can constrain the behavior of a class.

	Interfaces can be a special kind"abstract class" 
	abstract class	Facilitate code reuse (inheritance),Rewrite..)      
	Interface	Favorable for code maintenance/Extensions (interfaces can inherit more)
	Interface: A procedural extension that generally represents a capability. 
		  Java Is a single inheritance interface is multi-inherited and abstract, restricting the way a class must implement a method (a polymorphic one)		

JAVA Interface:
	1.All properties in an interface are,Global Static Constant,And constants must be defined with an initial value or compilation errors;(static const: Interface cannot be instantiated)
	2.All methods in an interface are abstract methods (abstract method subclasses non-abstract classes must implement methods)
		Jdk1.7: ......
		Jdk1.8: Then there may be in the interface: static Modified method; And can give method images,Property defaults are the same: declare the default method body;
				//When an interface has n class implementations, when an abstract method is added, N multiple implementation classes will fail...
				public static  void Method(){ //Method body}; //Unlike ordinary static methods, class objects cannot be implemented through interfaces. Calls can only be made through interface names.
				public default void Method(){ //Method body}; //The default method, Implementing Classes, can choose to override/not override. Classes implement multiple interfaces and, when the same default method exists, need to override all at once;The default method has the same name as the method of the inherited class, preferring the parent class.
		Jdk1.9: Private methods are allowed in interfaces:
				private void Method Name(){  };        //Solve the problem of duplicate code between multiple default methods;
				private static void Method Name(){  }; //Solve the problem of duplicate code between multiple static methods;
	3.Interface is not a class,therefore: Cannot declare that a constructor cannot be instantiated; 
	4.Interfaces can be extends Implement Inheritance: An interface can inherit multiple interfaces,Classes cannot inherit interfaces (interfaces inherit comma-separated interfaces)
	5.A class can inherit a class,Implement Interface(Multiple interfaces"," Comma delimitation must implement all methods of the interface,otherwise,Define as abstract class...)
	6.Interface has no static code block.....

	JAVA Define interfaces
		public interface Interface name A{ }   //Class to interface It is not a class
		public interface Interface A extends Interface,Interface..{  } //Interfaces inherit multiple interfaces, comma-separated
		public class extends Inherit parent class implements Interface,Interface...{  }  //Class inherits classes, implements implement interfaces, multiple interfaces separated by commas 

static modifier:

static Static,Can be decorated: attribute,Method,code block,Internal Class (static Decorated are loaded by class loading.....);
Use static Modifier property: called static property: static Basic Data Type Property Name;
	// The attributes (member variables) in a class can be divided into static variables (class variables) or non-static attributes (called instance variables) according to whether they are modified by static or not. 
		(Local variable is not allowed static Modification,..because static Is implemented by the class loading process.)
	Instance variable:	
		We create multiple class objects,Every object has a set,Non-static attributes in classes;When modifying one of the objects	Of,When a non-static property is present,Does not cause property values to be changed in other objects;
	Static variable:	
		We create multiple class objects,Multiple objects share the same static variable,When a static variable is modified through an object,The value that causes other objects to call this static variable is modified;
	// Static modifiers belong to this class. All objects created by this class use a static variable together!!
	// (static modifies variables not in the heap, but in the method area....)
	// Static variables are loaded as classes are loaded, earlier than object creation (new for objects); 
	// So it can be called by: class. static variable, because the class is only loaded once, the static variable takes up only one share in memory;
	// Attributes can be multiple objects and shared without changing depending on the object. static modifications can be set

Use static Decoration method: called static method(Conversely: Instance method):  public static void ff(){ //Code block}; //main is also a static method
	// Static methods: Only static properties/static methods can be invoked (or instance methods/instance properties can be invoked by creating objects.
	// The this/super keyword cannot be used in static methods:
			this Is the current object,and static Method,Class loading precedes any instance object;
			contradiction(therefore static Nor can the constructor be modified:Constructor's super();/this();Default first line initialization.... ); 
	// Instance method: You can call either a non-static method/property or a static method/property;
	// Methods that manipulate static properties, usually set static, have some tool classes, and can also be set as static modifiers.Convenient call

Method not definable static Variables so class variables cannot be local variables;
java Middle Class Properties/Class methods can be: Class name/object . Visit!And instance properties/Instance methods can only pass objects . Visit!

Code block:

code block(Code block): Java Use{ }Enclosed code is called a code block!
		Local Code Block
			grammar:	{ ... }
			Method appears {  } 	
			Equivalent to a small method in the method,You can limit the scope of variables(life cycle),Early release,Increase Code Utilization;
		Construct Code Block(Non-static code block)
			grammar:	 { ... }
			Appear in class { }  Trigger takes precedence over constructor when instance object; (Class per: new class(); //Called every time an object is created)
			Differences between building blocks of code and constructors:
			Constructing code blocks is a uniform initialization of all objects,The constructor initializes the corresponding object.
			Because constructors can be multiple,What object will be created by running which constructor,But no matter which object is created,The same block of construction code is executed first.
			In other words,The construction code block defines the initialization content common to different objects.
		Static Code Block 
			Appear in class, static Modify Code Block: Commonly used to initialize classes,Execute first when loading,And the static code block class loading process only executes once;
			static{ //Code body};	 
			//There can be more than one static code block in a class, which executes first during class loading one by one.	
			//About inheritance: You can call: property/method in the code block;Note that static methods/attributes are not static methods/attributes;

		Synchronize Code Blocks: Solving multithreaded problems...Below↓↓
			Synchronized (Britain: C Krynes)(Chinese translation: synchronization) 
			Synchronization code block refers to being Java in Synchronized Code Blocks Modified by Keyword,stay Java in,Synchronized Key word
			Not only can it be used to decorate code blocks,It can also be used to modify methods,Is a thread synchronization mechanism
			cover Synchronized Keyword-modified blocks of code are added with built-in locks.

			It should be noted that Synchronized Synchronizing code blocks is an expensive operation,So we should try to minimize what is synchronized
			In many scenarios,We don't need to synchronize the whole method,Just synchronize part of the code,That is, using synchronous code blocks ( JDK There are many applications in the source code)

final constant modifier:

final Constant modifier:
	constant: Will not change during program run ,Can only be referenced,Cannot be reassigned,Values can only be modified at definition time;
	final Modifier class cannot be inherited/Inherit it Class:final class Class name{ }                 // Then all the methods in the class are implicitly set to final modification, the class is not inherited, how to override?So you can't be with abstract / interface interfacets either!   
					//For example: System class String class!StringBuffer class!	

	final Modifiers cannot be overridden:         private final Return value type method name(){ };Errors will occur!   // Subclass inherits parent override // final representation which cannot be overridden i.e. inheritable, but defined private methods cannot be inherited and therefore will not be overridden so there are conflicts... private can be set without; 
	final Modifier variable cannot be re-assigned:   static final Data type variable name = value;    
	final Modifying Attributes,Mutator: Show initialization static code block code block initialization constructor initialization!
	// Final can be used inside a method or as a parameter!`Estimates are not used often!`
	// Global constants (declare assignment/constructor assignment, after which the value cannot be modified, but when assigning it use: rand.nextInt(10); //A call to a class object after assigning a random integer within 0-10 does not ensure that this is a consistent value...) the static modifier makes each class object constant the same value (the access modifier is arbitrary) 
	// Membership constants are arbitrary: static modifications cannot be made within a method, and assignments cannot be made once to modify ^^;
 	Be careful:	fianl Modify reference types,reference type,Address value cannot be modified!! eg: fianl A Object Name = new A();  Objects can't be created later new A();//Changing the reference address value will result in an error!But the internal value of the object.attribute will not, not change the address value;
			fianl Modifying the basic data type value itself does not fix the,(Variable names are usually between all uppercase words _ Separate)	
			//JVM/java applications cache final variables and therefore have high performance~

Keywords: Java

Added by konrad on Thu, 02 Sep 2021 19:10:41 +0300