Posts

Visual studio code:Is it worth your time?

I am not a fan of Microsoft but these days I became a fan of IDE called  “Visual studio code ”.Before jumping into the discussions I want to talk about the other IDE’s. Netbeans .Netbeans is great,but it serve a special purpose,i.e,creating Java based applications,you get JS,Go,python support but it is limited to certain extent.Then comes the next candidate. Eclipse .I was using eclipse when started doing android developement.At that time there was no android studio.I was the only choice left for me.Eclipse is really fast and smooth.It also has git support like Netbeans.But similiar to netbeans it can’t detect new programming languages and hence we can’t get autocomplete feature.For Java and C++,it’s great Sublime text : Not an IDE but text editor still counts.Sublime text gives tough competition to VS code but as it is just a text editor there are basic features missing such as in build terminal,debugging,git support,split screen view.Which is why I left it also. Webstorm : Mai

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

Method overloading,overriding and need of it,Concept of object

Image
Method overloading : Let me get this straight,method overloading simply means same method with different parameters either of different data-type or different parameter size.Return type must be same. Here's the example: Valid overloading of methods: void foo():nothing in the parameters list void foo(int num):one  parameter of type int void foo(int a,int b):two parameters of type int void foo(float a,float b): two parameters of type float void foo(int num,float tot): two parameters of type float and int In-Valid overloading of methods: If the parameters of the at-least one method is exactly the same invalid overloading. Need of overloading methods?? Method overloading is needed because there are situations where a single method have to do several kind of work.Suppose there is a method name calc_area that calculates area of different figures such as: Circle:single parameters with float value  calc_area(float r). Triangle:Two parameters(base and ht,) with float va

Exceptions and exceptional handling

Exceptions: What are exceptions you may ask,exceptions are flaws in the programs that are to be taken care of.They disturb the normal flow of the program and creates serious problems if not handled properly.They can be run-time or compile time or you may say unchecked or checked exceptions.But what are errors then,exceptions that cannot be recovered  are called errors.For example:Programmer has declared an array of objects of string class of size n,but has inserted greater than n value,its an array-index-out-of-bound exception,or if called the method of a class that neither exist on the package.There are lots of predefined exceptions in java including them.  There are basically two types of exceptions as I said,checked and unchecked exceptions. Checked exceptions are notified while compiling the program,i.e. the compiler checks that it would cause further problem,that's why they are called checked exceptions.Examples are:IOExeption,sqlException. Unchecked exceptions are non-