Skip to main content

Posts

Showing posts from April, 2019

Java Collection Framework - In 15 Mins

Collection framework is use for storing data in program. Collection framework contains most of data structure like LinkedList, Set, HashMap etc already implemented for you to direct use in program and also gives you flexibility to write own kind of data structure. Java collections framework data structure: Lists: Contains list of objects. Java provides 3 type of ready to use list. ArrayList Vector LinkedList Sets: Contains unique objects, does not allow dublicates. Java provides 3 type of sets, these are HashSet LinkedHashSet TreeSet Maps: Contain key:value data structure, value only access by key. Java provides 4 type of Map. HashMap Hashtable LinkedHashMap TreeMap Queues: Perform FIFO (first in first out) PriorityQueue Java Collection Interface And Collections Util Class Collection is an interface which is implemented by all data structure in java, except Map. Maps (HashMap, LinkedHashMap, Hashtable, TreeMap) are not define by Collection interface, th

What Is Exception in java?

Exceptions are exceptional conditions in program flow. What is the exceptional conditions? You going to read a file. Exceptional condition: File is not found.(FileNotFound Exception) You creating a new file. Exceptional condition: No space in memory for new file, you dont have rights to create a new file in drive. You are performing some operation on object. Exceptional condition: object is null.(NullPointer Exception) Mathematical exceptions like number divide by zero.(ArithmeticException) Array related exception like accessing an index which not in array(ArrayOutOfBound Exception). There are many cases where exception can occurs in your program. For your program runs as you expected,You need to perform exception handling for exceptional conditions but before go to exception handling lets know about Exception in java. public class Test{ void printName(){ System.out.println("Test"); } public static void main(String[] args) { Test test