Core java
- 29 January
How to get size of file in java
In this post, we will see how to get size of file in java. We can directly use java.io.File ‘s length method to get its size in bytes. We can convert it to KB and MB accordingly. [crayon-67443a5222454265132230/] When you run above program, you will get following output: [crayon-67443a522245b951806714/]
- 29 January
Java get file extension
In this post, we will see how to get extension of file in java. As java.io.File does not provide any direct method for getting extension of file. This is used when you want to process file differently on the basis of its extension. I have worked on a project where I required this utility method. […]
- 25 January
How to convert String to Date in java
In this post, we will see how to convert String to Date object in java. It is used when we have formatted String and need to convert it to Date object.You may also check how to convert Date to String Java program: [crayon-67443a5222752457574902/] When you run above program, you will get following output: [crayon-67443a5222755418260101/]
- 25 January
How to Convert Date to String in Java
In this post, we will see how to convert date to string in java. It is more of utility which is mostly used while displaying dates in different string formats while generating any pdf or excel reports.You may also check how to convert string to date Java program: [crayon-67443a52227f9625178246/] When you run above program, you […]
- 15 December
How to find GCD and LCM of two numbers in java
In this post, we will see how to find Greatest common divisor(GCD) and Least Common Multiple(LCM) in java. GCD is calculated using Euclidean algorithm and LCM is calculated using reduction by GCD Eucid algo for calculating GCD is: Lets say , there are two numbers , a and b so GCD of two numbers = […]
- 05 December
BlockingQueue in java
BlockingQueue is introduced in java with concurrent package with ConcurrentHashMap. It is thread safe queue to put and take elements from it. BlockingQueue is special type of queue which is used when one thread produces object and another thread consumes it. Producer thread will keep inserting objects to queue until it reaches upper limit. Once […]
- 12 November
Add two numbers represented by Linked List in java
If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions. Java Linked List Interview Programs: How to reverse a linked list in java How to reverse a linked list in pairs in java How to find middle element of linked list in java How to detect […]
- 12 September
Difference between Iterator and ListIterator in java
In this post, we will see difference between Iterator and ListIterator in java. They are both used for traversal but it is good to point out differences between them. Iterator vs ListIterator: Parameter Iterator ListIterator Traversal Iterator can be used to traverse List,set, Queue ListIterator can be used to traverse only List. Traversal direction Iterator can […]
- 12 September
TreeSet in java
In this post, we will see TreeSet in java. Java TreeSet have following properties: It can contain only unique element. It stores objects in ascending order by default, It implements NavigableSet interface which extends SortedSet. When you put objects in TreeSet, it must implement Comparable interface. Lets understand it more with the help of example. […]