Java encapsulation, inheritance and polymorphism
encapsulation
Example:
//student class
public class Student {
//Property private get/set
private String name;
private int age;
private char sex;
//Provide some public get and set methods
//get this data
public String getName() {
return this.name;
}
//set assigns a value to this property
public void setName(String name) {
this ...
Posted by sunil.23413 on Thu, 17 Feb 2022 10:42:21 +0100
Factory mode of design mode
Factory mode
And Singleton mode Similarly, the factory pattern also belongs to a kind of creative design pattern. Singleton mode is used to ensure that there is only one instance of a class, while factory mode is used to create different objects related to types. It also has different implementation methods. It can be subdivided into simple fa ...
Posted by intodesi on Thu, 17 Feb 2022 10:38:31 +0100
Three features of Java
Three features of Java (encapsulation / Inheritance / polymorphism)
1. Encapsulation
Benefits of encapsulation:
Hide information (permissions) and provide specific method accessEasy to add control statementsConvenient modification and Implementation
Specific performance of packaging:
Attributes are decorated with private The method is mo ...
Posted by mysqlnewjack on Thu, 17 Feb 2022 08:32:38 +0100
Release idea with jar and war package
Then declare that in the following packaging process, the scope always uses the default scope
<!-- Used to compile JSP -- >
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<!--<scope>runtime</scope& ...
Posted by daiwa on Thu, 17 Feb 2022 08:21:29 +0100
Chat thread pool ThreadPoolExecutor
problem
Let's talk about three questions first and look at the source code with questions:
How does the thread pool keep the core thread from dying?If the number of core threads is 0, will new tasks be queued first or run directly? Will the process pool eventually die out?Allow the core thread to timeout. Where is the impact point
Examples
...
Posted by rayk on Thu, 17 Feb 2022 07:55:52 +0100
Sequential consumption of RocketMQ MessageListenerOrderly()
consumer.registerMessageListener(new MessageListenerOrderly() {
@Override
public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) {
for (MessageExt msg : msgs) {
System.out.println(new String(msg.getBody())+" Thread:"+Thread.currentThread( ...
Posted by gvanaco on Thu, 17 Feb 2022 07:29:29 +0100
Java programming ideas Chapter 10 internal classes
Inner class: put the definition of one class inside the definition of another class. Advantages: organize some logically related classes together (elegant and clear), and control the visibility of internal classes.
10.1 creating internal classes
Put the definition of the class inside the peripheral class
public class Parcel1 {
class Des ...
Posted by tranzparency on Thu, 17 Feb 2022 05:35:31 +0100
Comparison between Comparable and Comparator based on Java
Comparison between Comparable and Comparator in Java
Introduction to Comparable
Comparable is a sort interface.
If a class implements the Comparable interface, it means that "this class supports sorting". That is, classes that implement the Comparable interface support sorting. Assuming that there is a "List (or array) o ...
Posted by kevo1162 on Thu, 17 Feb 2022 05:25:03 +0100
java multithreading principle learning notes
1, Preliminary understanding of java thread
1. java create thread
Several ways of creating threads in java
Inherit Thread classImplement Runnable interfaceCreate a thread pool using ExecutorServiceImplement the Callable interface to create a thread with a return value
Example:
//Inherit Thread class
public class MyThread extends Thread {
...
Posted by ckdoublenecks on Thu, 17 Feb 2022 05:01:07 +0100
XII [Java] object oriented abstract classes and abstract methods
catalogue
01 abstract class
1.1 examples of abstract application scenarios
1.2 abstract precautions
1.3 practice of abstract class
1.4 anonymous subclasses of abstract classes
1.5 concrete application of abstraction: template method
1.6 practice of abstract class
01 abstract class
With the definition of new subclasses in the inherit ...
Posted by cabldawg on Wed, 16 Feb 2022 22:54:58 +0100