java

HelloWorld 基础语法

人走茶凉 提交于 2021-02-18 10:45:00
所有内容取自菜鸟教程 public class HelloWorld { /* 第一个Java程序 * 它将打印字符串 Hello World */ public static void main ( String [ ] args ) { System . out . println ( " Hello World " ) ; // 打印 Hello World } } 打开记事本,把上面的代码添加进去; 把文件名保存为:HelloWorld.java; 打开cmd命令窗口,进入目标文件所在的位置,进入E: 在命令行窗口键入 javac HelloWorld.java 按下enter键编译代码。如果代码没有错误,cmd命令提示符会进入下一行。(假设环境变量都设置好了)。 再键入java HelloWorld 按下Enter键就可以运行程序。 编写Java程序时,应注意以下几点: 大小写敏感 :Java是大小写敏感的,这就意味着标识符Hello与hello是不同的。 类名 :对于所有的类来说,类名的首字母应该大写。如果类名由若干单词组成,那么每个单词的首字母应该大写,例如 MyFirstJavaClass 。 方法名 :所有的方法名都应该以小写字母开头。如果方法名含有若干单词,则后面的每个单词首字母大写。 源文件名 :源文件名必须和类名相同。当保存文件的时候

java.util.ConcurrentModificationException when removing elements from a hashmap

陌路散爱 提交于 2021-02-18 10:44:07
问题 I am learning about HashMap class and wrote this simple program. this code works good for adding elements to the hashmap and while removing elements from the hashmap , I am encountering java.util.ConcurrentModificationException for example here is a copy of my terminal, [ravi@doom test]$ java TestHashMap .....MENU..... 1. Add 2. remove key 3. remove value 4. display 7. Exit Your choice :1 Key : A Value : 1 Key/Value : (A,1) added to storage. .....MENU..... 1. Add 2. remove key 3. remove value

Problems with touch input and OpenJDK 11 with JavaFX 11

只愿长相守 提交于 2021-02-18 10:41:08
问题 I'm working on a JavaFX project and would like to switch from Oracle JDK 1.8 to OpenJDK 11. So far the transition has been pretty seamless, but there is still one main problem related to touch/mouse input that's causing some trouble. The JavaFX UI is supposed to run on a touch-enabled device, which used to work straight out of the box with Oracle JDK 1.8. When I touch the screen, the following sequence of mouse events is fired as expected: MOUSE_PRESSED MOUSE_RELEASED MOUSE_CLICKED After

Run JUnit tests from a dependency jar in Eclipse

限于喜欢 提交于 2021-02-18 10:38:49
问题 I have some JUnit tests that contained in a .jar that is intended to be used as a library. The library contains some tests that should be run whenever the library is used in another project. However when I create a new project using the library and run JUnit on it in Eclipse then the tests in the dependency .jar don't run / don't get detected by the JUnit test runner. I get the message: No tests found with test runner 'JUnit 4'. Is there a way I can configure the dependency .jar so that the

Generic type parameters inference in method chaining

痞子三分冷 提交于 2021-02-18 10:36:45
问题 After reading this question, I've started to think about generic methods in Java 8 . Specifically, what happens with generic type parameters when methods are chained. For this question, I will use some generic methods from Guava's ImmutableMap , but my question is more general and can be applied to all chained generic methods. Consider ImmutableMap.of generic method, which has this signature: public static <K, V> ImmutableMap<K, V> of(K k1, V v1) If we use this generic method to declare a Map

Combine Javadoc for multiple modules into a single collection

房东的猫 提交于 2021-02-18 10:33:28
问题 I have a Java application consisting of several modules. I'd like to generate Javadoc for all of them together: that is to say, from these several modules, I'd like a single collection of HTML files with a single index.html , a single allclasses-frame.html etc. and the various hyperlinks should work across modules. I use Maven but I'm not necessarily constrained to Maven-specific solutions. This will be performed by a cron job so other tools could also be used. What is the most

Types in a LambdaMetaFactory

女生的网名这么多〃 提交于 2021-02-18 10:28:11
问题 I get an exception when I call metafactory . It says: java.lang.invoke.LambdaConversionException: Incorrect number of parameters for instance method invokeVirtual my.ExecuteTest$AProcess.step_1:()Boolean; 0 captured parameters, 0 functional interface method parameters, 0 implementation parameters I do not understand all from the documentation of LambdaMetafactory.metafactory . I have problems figuring out the correct parameters: MethodHandles.Lookup caller -- thats easy String invokedName --

Dropwizard : New admin resource

♀尐吖头ヾ 提交于 2021-02-18 10:27:26
问题 I'm using Drowpizard 0.7.1, but perhaps I will upgrade to 0.8.4 very soon. Does anyone know how to add a admin resource to dropwizard, that is shown in Operational Menu like the example below? Operational Menu Metrics Ping Threads Healthcheck CustomAdminXy 回答1: I don't think you can do this easily. The AdminServlet is created when the ServerFactory is built. It may be possible to extend DefaultServerFactory and override createAdminServlet to create a custom Admin servlet with your links etc..

Dropwizard : New admin resource

£可爱£侵袭症+ 提交于 2021-02-18 10:27:26
问题 I'm using Drowpizard 0.7.1, but perhaps I will upgrade to 0.8.4 very soon. Does anyone know how to add a admin resource to dropwizard, that is shown in Operational Menu like the example below? Operational Menu Metrics Ping Threads Healthcheck CustomAdminXy 回答1: I don't think you can do this easily. The AdminServlet is created when the ServerFactory is built. It may be possible to extend DefaultServerFactory and override createAdminServlet to create a custom Admin servlet with your links etc..

Tesseract - ERROR net.sourceforge.tess4j.Tesseract - null

丶灬走出姿态 提交于 2021-02-18 10:23:08
问题 Created a java application that uses Tesseract in order to convert a given image or pdf to a string format, when running it on my machine as a unit test using junit it runs great but when running the full system which is a restFul API run by tomcat that receives the image and runs Tesseract it gives me the following error: 23:22:36.511 [http-nio-9999-exec-3] ERROR net.sourceforge.tess4j.Tesseract - null java.lang.NullPointerException: null at net.sourceforge.tess4j.util.PdfUtilities