![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
java
Alex要努力
不积跬步无以至千里,不积小流无以成江海!
展开
-
算法-删除并获得点数
题目来自leetcode第740题。class Solution { public int deleteAndEarn(int[] nums) { int maxVal = 0; for(int i : nums){ maxVal = Math.max(maxVal,i); } int[] sum = new int[maxVal+1]; for(int i : nums){原创 2021-05-05 14:02:27 · 101 阅读 · 0 评论 -
算法-拼写错误
我叫王大锤,是一家出版社的编辑。我负责校对投稿来的英文稿件,这份工作非常烦人,因为每天都要去修正无数的拼写错误。但是,优秀的人总能在平凡的工作中发现真理。我发现一个发现拼写错误的捷径:三个同样的字母连在一起,一定是拼写错误,去掉一个的就好啦:比如 helllo -> hello两对一样的字母(AABB型)连在一起,一定是拼写错误,去掉第二对的一个字母就好啦:比如 helloo -> hello上面的规则优先“从左到右”匹配,即如果是AABBCC,虽然AABB和BBCC都是错误拼写,应该优原创 2021-05-04 15:57:40 · 147 阅读 · 0 评论 -
java final修饰的变量
在学习lombok时,文档中有这么一个例子:public class LombokTest { @Test public void example() { val example = new ArrayList<String>(); example.add("Hello, World!"); val foo = example.get(0); System.out.println(foo.toLowerCase(原创 2021-04-09 17:50:56 · 197 阅读 · 0 评论 -
String str=new String(“a“)和String str = “a“有什么区别?
https://www.cnblogs.com/aspirant/p/9193112.html在做面试题的时候这是一个常考的基础知识点。看了上面这篇文章之后,恍然大悟。转载过来,同时加上自己的一些总结:1. jvm虚拟机中大体分为如下几个部分:线程私有的(虚拟机栈、Native栈、PC),线程共享的(方法区、堆等),方法区中包含一个常量池。2. 通过 string str = “abc” 创建字符串,“abc"是常量,去常量池中寻找是否存在,如果存在,则将地址存放到栈中的str,如果不存在,在常量池中原创 2020-11-18 17:48:57 · 431 阅读 · 0 评论 -
java 向上转型 & 向下转型
参考博客请参考上述博客中的代码。注解:向上转型的主要意义在于:当我们需要多个同父的对象调用某个方法时(重写的父类中的方法),通过向上转换后,则可以确定参数的统一,方便程序设计。向下转型的主要意义在于:通过一个形参为基类型的入口传入子类型的参数,通过向下转型还原为子类型,调用子类型中(特)有的方法,这便是多态。...原创 2020-10-27 14:19:13 · 1174 阅读 · 1 评论 -
Spring注解的使用和组件扫描
添加链接描述原创 2020-10-16 16:03:09 · 190 阅读 · 0 评论 -
java random
If two instances of Random are created with the same seed, and the same sequence of method calls is made for each, they will generate and return identical sequences of numbers. In order to guarantee this property, particular algorithms are specified for th原创 2020-07-09 16:01:58 · 76 阅读 · 0 评论