How-to articles, tricks, and solutions about JAVA
To return an array in Java, you can simply specify the array type as the return type of the method.
Yes, you can add jars to the Maven build classpath without installing them.
To accept a server's self-signed SSL certificate in a Java client, you can create a custom javax.net.ssl.X509TrustManager and use it to override the default trust manager.
To get the month integer from a java.util.Date object in Java, you can use the getMonth() method of the java.util.Calendar class.
To parse a JSON object in Java, you can use the org.json library.
If you are using Hibernate and you see the error "MultipleBagFetchException: cannot simultaneously fetch multiple bags", it means that you are trying to fetch multiple collections of an entity using a single Hibernate query.
In Java, you can create an object in the following ways:
No, the isEmpty() method of the java.util.List interface does not check if the list itself is null.
To calculate the running time of a program in Java, you can use the System.currentTimeMillis() method to get the current time in milliseconds before and after the program runs.
To access a variable from another class in Java, you can use the following steps:
To perform a mouseover (hover) action in Selenium WebDriver using Java, you can use the Actions class.
If you are seeing the error "package javax.xml.bind does not exist" in your Java 11 project, it means that the Java XML Bind (JAXB) API is not included in the classpath.
In Java, you can initialize multiple variables to the same value in a single statement by separating the variables with a comma.
If you are seeing the error "No Persistence provider for EntityManager named [persistence-unit-name]" in your Java application, it means that the persistence provider (e.g.
To switch to a new browser window in Selenium, you can use the switchTo() method with the WindowHandle of the new window.
To put input from a Scanner into an array in Java, you can use a loop to read the input and store it in the array.
No, Java does not have a goto statement.
In Java, a KeyValuePair is a data structure that represents a pair of keys and values, similar to a Map.
If IntelliJ is saying "No beans of type 'X' found for autowiring" for a repository that you are trying to autowire, it means that the Spring application context does not contain a bean of the specified type.
To add a context path to a Spring Boot application, you can use the server.context-path property in the application's application.properties file.
To read a properties file in Java, you can use the Properties class from the java.util package.
To parse a JSON string in Java, you can use the JSONObject class from the org.json package.
If you are getting the error "Your security settings have blocked a local application from running" when trying to run a Java application, it means that your security settings are preventing the application from running.
To select a dropdown value in Selenium WebDriver using Java, you can use the selectByValue or selectByVisibleText methods of the Select class.