Reversing an array means rearranging the elements of the array in such a way that the last element is placed at first position, second last element to second position and…
Most applications require calculating current date for different reasons. It may be for logging events, for saving the creation, updation or deletion time of entities, recording the login details of a user and so on. Java provides different methods to calculate current date and time. Following article explains different methods to obtain current date and/or time in java. (more…)
What is Stack ?
A linear data structure which stores newly added items at its top and retrieves newly added items from its top. Consider a pile of books where each new book added to the pile is placed at its top and at the time of removal, the book at the top is removed. A stack works on LIFO (Last In First Out) principle and supports only two operations : (more…)
What is tag name ?
There are various types of HTML elements such as input elements, anchor tags, drop downs etc. Each element has a unique syntax by which it is defined and identified. This syntax is its tag name. For Example, an input element is defined using <input> tag, anchor element by <a> tag, drop down by <select> tag and so on. (more…)
Meaning of Autowiring
Autowiring means initializing objects contained in a class automatically. Suppose you have a class which contains reference of another class as a member field. Now in order to initialize the member field you create an object of member field type and assign it manually (when not using Autowiring). (more…)
Suppose your application has to read an XML file and store its contents in a database such as each set of nodes is created as a record. For Example, there are multiple employee nodes with employee details in your xml and you have to store each employee details as a record in database. The process would be pretty easy if you have some mechanism to get the employee details form the XML in the form of java objects as then you could iterate those objects and store them by using JDBC or directly save them using any ORM framework (such as Hibernate). (more…)
Suppose your application fetches a record from a database and it needs to create an XML out of it. There are chances that your application uses an ORM framework such as Hibernate and the database record is fetched in the form of entity classes. Now you have two ways, iterate over the object properties and create each XML node manually using the XML DOM apis (How to create XML from Java program using DOM parser) or follow the approach detailed here. (more…)