从零开始JVM(一):初探JVM运行时数据区域

2021-10-24
阅读 5 分钟
2.3k
最近重新开始阅读《深入了解Java虚拟机》这本书,就想着用一个系列文章来记录和分享自己的心得。为什么要说”重新“呢?是因为这本书我在多年前就买了,中间也曾翻来覆去的看过。这个”翻来覆去“可以说是非常的生动形象,因为我不仅从前往后看,也从后往前看了这本书。但是,这并不是一个值得骄傲的过程,因为我之前看的时...
封面图

一劳永逸的优化!并发RPC调用小工具

2021-10-04
阅读 8 分钟
2.9k
系统的性能优化是每一个程序员的必经之路,但也可能是走过的最深的套路。它不仅需要对各种工具的深入了解,有时还需要结合具体的业务场景得出定制化的优化方案。当然,你也可以在代码中悄悄藏上一个Thread.sleep,在需要优化的时候少睡几毫秒(手动狗头)。性能优化这个课题实在是太浩瀚了,以至于目前市面上没有一本优...

猫头鹰的深夜翻译:趣谈Java Exception

2021-10-01
阅读 3 分钟
2.4k
Java异常类(Exception)是用来处理异常程序行为的一组类。在这篇文章中,我将介绍如何使用Java异常类,以及在程序中如何设计Java异常体系。Exception类是Java体系中非常重要的一环,每一个程序员都必须熟悉并掌握它。

Mybatis Generator Plugin悲观锁实现

2021-09-27
阅读 12 分钟
4.3k
Mybatis Generator插件可以快速的实现基础的数据库CRUD操作,它同时支持JAVA语言和Kotlin语言,将程序员从重复的Mapper和Dao层代码编写中释放出来。Mybatis Generator可以自动生成大部分的SQL代码,如update,updateSelectively,insert,insertSelectively,select语句等。但是,当程序中需要SQL不在自动生成的SQL范围...

记一次PageHelper分页未生效问题排查

2021-09-03
阅读 12 分钟
4.6k
排查的时候发现,count代码通过mybatis生成的sql语句中包含了分页参数,但是select语句却没有,因此将查询数据列表的请求放在计算总数据行数前面即可解决这个问题。

记一次logback配置文件未生效问题排查

2021-08-30
阅读 8 分钟
11.2k
最近在公司新建了一个JAVA微服务,采用的是springboot框架,logback作为日志模块的实现。在搭建的的过程中想起之前在文档中看到springboot支持用logback-spring.xml作为定制的logback配置文件。在这个文件中可以使用spring的定制化标签,比如可以根据当前生效的profile对日志文件进行配置,从而省去配置多份日志文件并在...

leetcode460. LFU Cache

2020-02-02
阅读 3 分钟
2.3k
Design and implement a data structure for Least Frequently Used (LFU) cache. It should support the following operations: get and put.

leetcode495. Teemo Attacking

2020-02-01
阅读 2 分钟
2k
In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking ascending time series towards Ashe and the poisoning time duration per Teemo's attacking, you need to output the total time that Ashe is in poisoned cond...

leetcode543. Diameter of Binary Tree

2020-02-01
阅读 1 分钟
2k
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.

leetcode540. Single Element in a Sorted Array

2020-02-01
阅读 2 分钟
2k
You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Find this single element that appears only once.

leetcode535. Encode and Decode TinyURL

2020-01-30
阅读 2 分钟
3k
TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl and it returns a short URL such as http://tinyurl.com/4e9iAk.

leetcode529. Minesweeper

2020-01-29
阅读 5 分钟
2.2k
You are given a 2D char matrix representing the game board. 'M' represents an unrevealed mine,'E' represents an unrevealed empty square, 'B' represents a revealed blank square that has no adjacent (above, below, left, right, and all 4 diagonals) mines, digit ('1' to '8') represents how many mines...

leetcode542. 01 Matrix

2020-01-27
阅读 4 分钟
2.3k
Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.

leetcode554. Brick Wall

2020-01-26
阅读 2 分钟
2.2k
There is a brick wall in front of you. The wall is rectangular and has several rows of bricks. The bricks have the same height but different width. You want to draw a vertical line from the top to the bottom and cross the least bricks.

leetcode538. Convert BST to Greater Tree

2020-01-26
阅读 2 分钟
2.2k
Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.

547. Friend Circles

2020-01-19
阅读 3 分钟
2.7k
There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, then A is an indirect friend of C. And we defined a friend circle is a group of students who are direc...

leetcode525. Contiguous Array

2020-01-18
阅读 2 分钟
2k
Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.

leetcode502. IPO

2020-01-09
阅读 4 分钟
2.1k
Suppose LeetCode will start its IPO soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the IPO. Since it has limited resources, it can only finish at most k distinct projects before the IPO. Help LeetCo...

leetcode556. Next Greater Element III

2020-01-07
阅读 2 分钟
2.1k
Given a positive 32-bit integer n, you need to find the smallest 32-bit integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive 32-bit integer exists, you need to return -1.

leetcode523. Continuous Subarray Sum

2019-12-31
阅读 3 分钟
1.9k
Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to a multiple of k, that is, sums up to n*k where n is also an integer.

leetcode503. Next Greater Element II

2019-12-28
阅读 2 分钟
1.9k
Given a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The Next Greater Number of a number x is the first greater number to its traversing-order next in the array, which means you could search circularly to...

leetcode519. Random Flip Matrix

2019-12-05
阅读 3 分钟
2.2k
You are given the number of rows n_rows and number of columns n_cols of a 2D binary matrix where all values are initially 0. Write a function flip which chooses a 0 value uniformly at random, changes it to 1, and then returns the position [row.id, col.id] of that value. Also, write a function res...

leetcode464. Can I Win

2019-11-30
阅读 3 分钟
2.7k
In the "100 game," two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach or exceed 100 wins.

leetcode516. Longest Palindromic Subsequence

2019-11-26
阅读 2 分钟
2.3k
Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.

leetcode480. Sliding Window Median

2019-11-24
阅读 5 分钟
1.8k
Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.

513. Find Bottom Left Tree Value

2019-11-17
阅读 1 分钟
1.5k
Given a binary tree, find the leftmost value in the last row of the tree.

leetcode508. Most Frequent Subtree Sum

2019-11-14
阅读 2 分钟
1.6k
Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as the sum of all the node values formed by the subtree rooted at that node (including the node itself). So what is the most frequent subtree sum value? If there is a tie, return al...

leetcode506. Relative Ranks

2019-11-12
阅读 3 分钟
1.6k
Given scores ofNathletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: "Gold Medal", "Silver Medal" and "Bronze Medal".

leetcode452. Minimum Number of Arrows to Burst Balloons

2019-11-08
阅读 2 分钟
1.5k
There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal, y-coordinates don't matter and hence the x-coordinates of start and end of the diameter suffice. Start is ...

猫头鹰的深夜翻译:开发者必须了解的分支发布模型

2019-11-08
阅读 5 分钟
2.5k
想要深入了解Git和中心化代码版本管理系统的优缺点比较,可以在网上自行查询,这个话题一直争论不休。作为一个开发者,我更倾向于使用Git。Git确实改变了开发者对代码合并和分支管理的认识。作为一个使用过传统的CVS工具的人,合并/开分支是一个比较恐怖的行为,迫不得已才执行一次。