![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
JAVA
文章平均质量分 67
qq_42591760
明欲,明理,明情。
展开
-
关于“No enclosing instance of type * is accessible. Must qualify the allocation with an enclo……”的总结与思考
报错的完整信息:No enclosing instance of type OutterClass is accessible. Must qualify the allocation with an enclosing instance of type OutterClass (e.g. x.new A() where x is an instance of OutterClass).错误的出现背景:Java在类中添加内部类,并在main函数中通过语句:OutterClass.I原创 2020-12-30 16:19:00 · 1948 阅读 · 0 评论 -
java.lang.Math.random() 如何取 [n,m] 的随机数
众所周知,java.lang.Math.random() 是用来取随机数的方法。今天就来讨论,如何利用该方法获取区间 [n,m] 的随机数。通过手册不难发现,Math.random() 方法其实还是在使用 java.util.Random 这个类。该方法返回一个区间为 [0.0,1.0) 的double型的随机数,以下给出手册中关于该方法的描述:Returns a {@code doub...原创 2019-09-08 09:39:10 · 789 阅读 · 0 评论 -
Java 中的 String 与 new String()
初学Java的小伙伴在学习到字符串时大多会有一个问题:为什么String作为一个类却可以直接声明定义如下——String string = "here is a string";而不是通常的类定义方法——String string = new String("here is a string");其实,这是Java为了效率提供的一种机制。在《Java语言程序设计》一...原创 2019-09-09 11:01:19 · 264 阅读 · 0 评论