The JDK 8 added a new Date and Time API (JSR 310) which introduces new date and time classes like LocalDate, LocalTime, LocalDateTime, and ZonedDateTime. Now, if you have a String e.g. "2016-12-14 03:30" then how do parse it to LocalDate, LocalTime, LocalDateTime and ZonedDateTime? Similarly, if you have an instance of those classes how you can format to the String you want e.g. in dd/MM/yyyy format, or USA or UK format? Well, Java 8 provides a utility class called DateTimeFormatter which can be used to parse/format dates in Java 8. It also provides several built-in formatter e.g. ISO date format and other to facilitate formatting of dates to String.
Learn Java and Programming through articles, code examples, and tutorials for developers of all levels.
How to convert JSON to Map in Java 8 without using third party libraries like Jackson or Gson
Hello guys, If you are working with JSON data then you may know that JSON is collection of key value pairs and that's why many times, you also need to convert them into a Map in Java. While there are many Java libraries like Jackson and Gson which provides support of parsing JSON to Java objects, there is not much support for JSON parsing or manipulation on standard JDK. While JSON parsing is still a long overdue, starting with JDK 8u60+ the built-in Nashorn engine is capable to convert JSON content into java.util.Map. No external dependencies are required for parsing JSON in to Map as you will learn in this article.
Can You Override static method in Java? Method Hiding Example
Top 95 Programming Interview Questions Answers to Crack Any Coding Job Interview
Top 30 Stack and Queue Data Structure Interview Questions for Practice
3 ways to check if checkbox is selected in jQuery - Example Tutorial
So, you have a checkbox and you want to check if its selected or not at runtime using jQuery. If that's what you want then continue reading. A checkbox is an HTML element with type="checkbox" and checked property is used to find out whether a checkbox is selected or not. There are several ways to find if your checkbox has this property or not in jQuery e.g. by using :checked, a pseudo selector or by using is() jQuery function or by using prop() function which is available from jQuery 1.6 onward. In this article, we will see examples of these approaches to check if a check box is checked or not.
Top 10 Frequently asked SQL Query Interview Questions Answers
Top 100 Data Structure and Algorithm Interview Questions for Java Programmers
How to remove duplicates from Collections or Stream in Java? Stream distinct() Example
5 Examples of map() and flatMap() in Java 8 Stream
Top 21 String Programming and Coding Interview Questions With Solutions
Top 21 jQuery interview Questions and Answers
Top 21 Maven Interview Questions Answers for Java Developers
Hello guys, for a Java developer, Maven in one of the essential tool and its used to build your Java application. Since most of the Java projects used Maven for building, it is expected from a Java developer that he knows Maven and knows it well. That's why Maven questions are quite common on Java developer interviews but I have seen many Java programmers coming to these interview unprepared and not able to answer most of the questions on tools like Maven, Gradle or even git. When I asked one candidate why don't you prepare for Maven before your Java interviews, he said, I wasn't able to find any list of Maven questions.
How String concatenation works in Java?
You can concatenate multiple String using + operator in Java. Even though Java doesn't support operator overloading, + operator is special, it performs addition if given operands are numeric and does String concatenation if one of them is String. Why it's important to know how String concatenation works? Well, more often that you can live without this knowledge but if you want to master Java then why not know little more detail. Apart from that it also helps you to avoid a performance mistake, which many Java devleoper do, concatenating String inside loop. When you concate two String literal e.g. "abc" + "cde" then compiler do this concatenation at compile time and this doesn't involve StringBuilder.
Concatenating two String literal
Concatenating String literal and String variable.
Things to remember:
1) Don't concatenate String in loop because Java creates a new StringBuilder() every iteration.
2) If two String literal are concatenated i.e. "Java" + "Script" then it happens at compilation time
2) When you concatenate a String literal and a String object, or two String object then it happens at runtime.
That's all about how String concatenation works in Java.
How to enable or disable form elements using jQuery? Examples
In last couple of tutorials you have learned how to get all selected checkbox and radio buttons, and in this tutorial, you will learn how to enable/disable form elements using jQuery. A form element e.g. a textfield, radio buttons and checkbox, all represented using input tag can be enabled or disabled by adding an attribute called "disabled". It's similar to "checked" attribute we have seen for checkbox and radio buttons. If this attribute is not present then element is enable, but if this attribute is present then you can use disabled=true to disable the form element and disabled=false to enable the form elements as shown in our example. Like previous example of checking/unchecking checkbox, you can use prop() jQuery function to enable/disable form element if you are running on jQuery 1.6 or higher version and attr() function if you are running on jQuery 1.5 or lower version.
How to shuffle a List in Java? Collections.shuffle() Example
How to Compare Two Dates in Java? Check If They Are Equal, Later or Earlier - Examples
What is transient variable in Java? Serialization Example
Difference between HashSet and HashMap in Java? Answered
Hello friends, if you have given Java developer interview then there is good chance that you may have come across questions like Difference between HashSet vs HashMap or HashSet vs TreeSet etc. In this article, we are going to discuss differnece between HashMap and HashSet, two of the popular Collection classes from JDK. The HashSet vs HashMap is a classical Java Collection interview question that focuses on What are differences between HashSet and HashMap in terms of features, usage, and performance. If you are in Java programming even for a year or so, you are likely to be familiar with What is HashSet in Java and What is HashMap in Java, these two are the most popular collection classes.
What is PATH and CLASSPATH in Java? Path vs ClassPath Example
The PATH and CLASSPATH are the two most important environment variables of the Java environment which are used to find the JDK binaries used to compile and run Java in windows and Linux and class files which are compiled Java bytecodes. From my personal experience I can say that PATH and CLASSPATH are the two most problematic things for beginners in Java programming language due to two reasons; first because in most Java courses nobody tells details of what is a PATH and CLASSPATH, What do PATH and CLASSPATH do, What is meaning of setting PATH and CLASSPATH, What happens if we do not set them, Difference between PATH vs CLASSPATH in Java or simply How Classpath works in Java, etc.