JavaSE_04 [ process control statement ]
JavaSE_04 [ process control statement ]
Today's content
for loop statementwhile loop statementdo... while loop statementbreakcontinue
Learning objectives
Understand the format and execution process of for statement Understand the format and execution flow of while statement Understand the format and execution flow of do... while statement ...
Posted by dinno2 on Wed, 09 Mar 2022 14:11:54 +0100
day18: File (construction method, creating and deleting files or folders, judgment, renaming and cutting, availability, filtering), recursion (traversing folder files)
I. review
1.HashMap set
Features:
A. the data structure is also a Hash table structure
B. It is unsafe in multithreading
C. the initialization capacity of the default array is 16
2. Comparison between HashMap and HashSet
The same point: they are stored in hash table structure
Differences:
The bottom layer of A.HashSet is imp ...
Posted by Ryan Sanders on Sat, 05 Mar 2022 02:13:27 +0100
Detailed explanation of JAVA multithreading
Detailed explanation of JAVA multithreading (II)
III Thread state
1. Five states
2. Thread method
methodexplainsetPriority(int newPriority)Change the priority of a threadstatic void sleep(long millis)Hibernates the currently executing thread for the specified number of millisecondsvoid join()Wait for the thread to terminatestatic voi ...
Posted by stilgar on Thu, 03 Mar 2022 17:04:36 +0100
[JavaSE series] generics and wildcards in Java
⭐ ♪ previous words ⭐ ️
This article introduces you to Java syntax - generics and wildcards. Generics and wildcards are very abstract concepts. In short, both can pass types as "parameters". However, generics are used when you know what type to pass in, while wildcards are used when you are not sure what type to pass in, This articl ...
Posted by onekoolman on Mon, 28 Feb 2022 11:07:54 +0100
Javase (day05: process control statement)
if selection structure
1. Classification
if single choice structureif double choice structureif multiple selection structure
2. if single choice structure
Syntax: if (conditional expression){ }Note: the code in curly braces (code block) will be executed only when the return value of the conditional expression is true
3. if double choice stru ...
Posted by sorenchr on Sat, 26 Feb 2022 15:15:52 +0100
Interview question: to realize a deadlock (Java version), the four necessary conditions for deadlock generation, how to avoid deadlock and how to solve deadlock
Implement the simplest deadlock (Java version)
```java
/**
* @author wall
* @date 2019/7/29 16:42
* @description Implement A deadlock: thread A obtains the lock held by thread B, and thread B obtains the lock held by thread A
*/
public class DeadLock {
//Define two locks
private static ReentrantLock lockA = new ReentrantLock();
...
Posted by Gen-ik on Sat, 26 Feb 2022 03:32:53 +0100
Java TreeSet set, binary tree
1, TreeSet
1. The bottom layer of TreeSet set is actually a TreeMap; At the bottom of the TreeMap set is a binary tree
2. The elements put into the TreeSet set are equivalent to the key part of the TreeMap set.
3. TreeSet set storage element features: unordered and non repeatable, but the stored elements can be automatically sorted in size o ...
Posted by vierme on Fri, 25 Feb 2022 14:33:35 +0100
Java --- object and polymorphism
Three characteristics of object-oriented: encapsulation, inheritance and polymorphism
encapsulation
In order to ensure the security of variables, we use encapsulation, do not care about the specific implementation details, but only access the members of the class through external excuses.
public class Student {
private String name;
p ...
Posted by brain on Thu, 24 Feb 2022 10:47:15 +0100
Detailed explanation of Java collection framework
Java collection framework (III)
Map interface
Characteristics of Map implementation class
Map: double column data, which stores the data of key value pairs, similar to the function of high school, y=f (x) Implementation class:
HashMap: as the main implementation class of Map; Unsafe thread and high efficiency; null key s and value s ca ...
Posted by Robin M on Sat, 19 Feb 2022 20:11:49 +0100
Why does HashMap concurrency cause dead loops?
Today, when studying the Java concurrency container and framework, we can see why we should use ConcurrentHashMap. One reason is: thread unsafe HashMap. HashMap will cause a dead loop when executing put operation concurrently, because multithreading will cause the Entry linked list of HashMap to form a ring data structure and fall into a dead l ...
Posted by jeff2007XP on Sat, 19 Feb 2022 06:28:36 +0100