Tag:code

  • DK7 switch’s support for string

    Time:2021-3-7

    Before JDK7, switch can only support byte, short, char, int or their corresponding encapsulation classes and enum types. After JDK7, switch supports string type. In the switch statement, the value of the expression cannot be null, otherwise NullPointerException will be thrown at runtime. Null cannot be used in the case clause, otherwise compilation errors will […]

  • Trust learning — define modules to control scope and privacy

    Time:2021-3-7

    Modules allow us to divide the code in the crates into groups to improve readability and reusability. The module also controls the privacy of the project, that is, whether the project can be used by external code (public) or internal implementation details but not for external use (private). For example, let’s write a library box […]

  • React: asynchronous update of usestate

    Time:2021-3-7

    introduce function App() { const [n, setN] = useState(0) const onClick = ()=>{ setN(n+1) Set n (n + 1) // at this time, we find that n can only + 1, not + 2 // setN(i=>i+1) // setN(i=>i+1) } return ( <div className=”App”> <h1>n: {n}</h1> <button onClick={onClick}>+2</button> </div> ); } ReactDOM.render(<App />, document.getElementById(“root”)); The react […]

  • C + + programming 02 — memory partition

    Time:2021-3-7

    Memory partition Four main memory partitions Stack 1 is the memory area allocated by the compiler when it is needed and cleared automatically when it is not needed. The variables are usually local variables, function parameters, etc. the pointer is also on the stack, but the stored data is in the heap. 2. Heaps are […]

  • Socket completes simple communication

    Time:2021-3-7

    Introduction of socket Socket, also known as “socket”, will send data through UDP / TCP protocol to realize simple communication between two machines. Note: if you want to use socket to realize simple communication between two machines, please make sure that the two machines are connected to the same local area network. Of course, socket […]

  • For loop traversal in JavaScript

    Time:2021-3-7

    General for loop traversal Define an array: Using the normal for loop traversal Can be used to traverse arrays Foreach traversal The traversal code is as follows This structure is more concise, but you can’t use break and other statements to jump out of traversal until all elements are passed to the calling function, but […]

  • Eslint forbidden in vue-cli3 project

    Time:2021-3-7

    If a Vue project is created from scratch with the scaffold vue-cli3, then don’t choose eslint when creating it. It’s really not easy to use. It’s to make the novice code more standardized. In fact, it’s to make your code have dozens of irrelevant errors all at once, and then you need to slowly modify […]

  • Update of IntelliJ idea 16 Preview

    Time:2021-3-7

    debugger Groovy expression Starting with version 16, evaluate expression and watches can be debugged with shorter and more expressive groovy expressions, which were previously only used for groovy code. thread In the past, crossing one thread meant restoring all the other threads, while version 16 only needed to restore the current thread. Source mismatch detection […]

  • Talk about git Series 1: git introduction and installation

    Time:2021-3-7

    1、 Version control 1. What is version control system A standard version control system (VCS) usually needs the following functions:Ability to create a repository for storing codeFacilitate code distribution to team members during collaborative developmentRecord the content, time and reason of each code modificationAble to create branches, which can be developed according to different scenariosAbility […]

  • Boot nginx in Linux

    Time:2021-3-7

    1、 Script vi /etc/init.d/nginx Modify the code of / etc / init.d/nginx as follows: #!/bin/bash # nginx Startup script for the Nginx HTTP Server # it is v.0.0.2 version. # chkconfig: – 85 15 # description: Nginx is a high-performance web and proxy server. # It has a lot of features, but it’s not for […]

  • Quickly building alink project with maven

    Time:2021-3-7

    The newly released version of alink 1.1.0 supports publishing to Maven central. Java developers can quickly build alink machine learning projects through Maven. This article will demonstrate a simple construction scheme, which is convenient for enthusiasts to get started quickly. Let’s talk about the related environment, windows system. The Jave editor used is interlij idea […]

  • [algorithm] implementation of classic sorting algorithm 1 in PHP

    Time:2021-3-7

    1、 Bubble sort Brief introduction of principle Bubble sort is a simple and common sort algorithm. It traverses the sequence of numbers to be sorted, compares the size of the two values, and exchanges the positions of the two wrong numbers to complete the sorting. Repeat the above operation until there is no exchangeable number […]