Posts

Showing posts from 2015

Lists in java

Lists in java: What is a list? A list is collection of data.For a real time example consider a list of groceries for a month.You can add,remove,clear,get items from a list.List is actually an interface. There are several lists collections available in java: Array list:Most important and useful type of list LinkedList:Similiar to arraylist with limited functionality Vector:Similiar to arraylist but it is synchronised class. Stack:LIFO(Last in first out) collection Common methods in a list: add(Object e),add(int index,Object e):adds an element(duh :<).For adding element at specific position pass parameter index. remove(int index):remove an element at position clear():clears out the list.Make list empty.

Four building blocks of Object oriented programming language

Four building blocks of Object oriented programming language Java is an object oriented programming language just like C++,small talk and python. An OOP language follows four basic rules: *Inheritance *Encapsulation *Polymorphism *Abstraction *Inheritance: The ability of a language to reuse previously written code and add further functionalities to the previously written code. How we use it in Java: BY EXTENDING CLASSES. Each child class inherits the functions and member variables from the parent class without even writing the whole code. *Encapsulation:  The ability of a language to  hide the important and private data and encapsulate into an single unit called "CLASS". How we use it in Java: By creating classes the data wrapped inside it and can only be accessed using the object(unless it is static data). *Polymorphism:  The ability of a language to  create a method with same name but multiple arguments each method do different work on different situation

Threads in java

Image
Threads in java What are threads :For understanding threads we must firstly know,what is a process? A process is a background activity running besides doing some works at a piece of time.A machine operating system runs a lot of processes to do a task such as opening a program,booting up,loading resources etc.So next question is what is a thread? A thread is a light weight process,i.e. threads do small piece of work in a particular duration.It has a start start,running state,waiting and terminated state.There is a default thread running in a java program,if you have noticed:its the main thread. Why do we need threads? Suppose in a situation where we are creating a project where a program does two or more piece of work at the same time,for example processing a mouse click on a button and opening the other frame of project at the same time.HOW CAN WE DO THAT??The power comes with multithreading. How threads works? The threads are started using start() method,that gives call

Basics of JDBC connectivity

JDBC connectivity: Or simplified as Java database connectivity.What is the fun when the program does not have a database to store to.So,here comes sql(a console based language specially for the data storage) to the rescue. Why is JDBC connectivity needed: Suppose you are working on large project called Library management and there are huge data to be stored and retrieved during the program execution.Such large data cannot be managed by simple file based databases.So,there is a need for a proper tool for this purpose.JDBC serves for this purpose.   How to do JDBC connectivity: First you will need jar file for JDBC driver. Link: JDBC driver for Mysql . If you are working on the eclipse,the right click on the project->project properties->java build path->(Bottom Left)add button->Path of the .jar file. Or you can create lib folder in your project and paste the jar file into it.That shoul work. JDBC connectivity is done in for steps: Loading the class with class.for