Category: Java

关于 @SuppressWarnings

Java compilers are increasingly capable of issuing helpful “lint-like” warnings. To encourage the use of such warnings, there should be some way to disable a warning in a part of the program when the programmer knows that the warning is inappropriate. The annotation type SuppressWarnings supports programmer control over warnings otherwise issued by a Java compiler. It […]

Guidelines for Wildcard Use

转自jdk8文档 One of the more confusing aspects when learning to program with generics is determining when to use an upper bounded wildcard and when to use a lower bounded wildcard. This page provides some guidelines to follow when designing your code. For purposes of this discussion, it is helpful to think of variables as providing […]

volatile 以及同步相关内容

volatile Fields The Java programming language allows threads to access shared variables (§17.1). As a rule, to ensure that shared variables are consistently and reliably updated, a thread should ensure that it has exclusive use of such variables by obtaining a lock that, conventionally, enforces mutual exclusion for those shared variables. The Java programming language provides […]

Java备忘

Java 11 与 Java 8 的区别 日期 Java 11 多了 LocalDate.EPOCH 常量的定义, Java 8没有这个变量 Java中标签的使用 An unlabeled break statement terminates the innermost switch, for, while, or do-while statement, but a labeled break terminates an outer statement.  Java中标签主要是用来中断或者跳转到指定循环(非中断/跳转语句直接所在的循环),以下是随手写的示例代码,仅为展示标签使用: 如果随机生成的l值是10的倍数,则中断do-while循环;如果l值对10取模余数是2,则跳转到第二个for循环。 Maven 3.3.1+ requires JDK 1.7+. Maven 3.3.1+ requires JDK 1.7+. Please set appropriate JDK at Settings | Build, Execution, Deployment | Build Tools | Maven | […]

简单Java Applet示例

下午看到一个涉及到Java Applet的问题,发现自己已经都不知道多少年没接触Applet了,稍微看一下,运行了个简单示例。 JDK8 – Java Applets A Java applet is a special kind of Java program that a browser enabled with Java technology can download from the internet and run. An applet is typically embedded inside a web page and runs in the context of a browser. An applet must be a subclass of the java.applet.Applet class. […]

Java Queues

Queue A collection designed for holding elements prior to processing. Besides basic Collection operations, queues provide additional insertion, extraction, and inspection operations. Each of these methods exists in two forms: one throws an exception if the operation fails, the other returns a special value (either null or false, depending on the operation). The latter form of the insert operation is […]

Java 17 available now

Java 17 LTS is the latest long-term support release for the Java SE platform. JDK 17 binaries are free to use in production and free to redistribute, at no cost, under the Oracle No-Fee Terms and Conditions. JDK 17 will receive updates under these terms, until at least September 2024. JDK 17 Documentation Java Language Updates […]