Java ArrayList

Ok today we gonna talk about Java Array List. Array List is very similar to array and we can store elements sequentially and access elements by indexed position. But the main difference between Array and Array List is, Array List is dynamic. It means It’s size can grow and shrink. but Array have a fixed size. OK got it? 🙂 It was a simple definition of Array List. Let’s know more about Array List.

Let’s look a simple code

import java.util.*;

class AList{
          public static void main(String args[]){
 ArrayList<String> al=new ArrayList<String>();//creating arraylist
 al.add("somba");//adding object in arraylist

Iterator itr=al.iterator();//getting Iterator from arraylist to traverse elements
   while(itr.hasNext()){   //also we can use for loop for traverse elements

In this code first we have imported java.util.* or we can import just java.util.ArrayList  class.

ArrayList<String> al=new ArrayList<String>();

Here we create new Array List object “al” and we give the object type as a String. If you want to create an Integer ArrayList you can do like this.

ArrayList<Integer> al=new ArrayList<Integer>();

Here we put “Integer”  integer class and not a “int” premitive.

Why we use ArrayList ?
* It can grow dynamically.
* It provides more powerful insertion and search mechanisms than arrays.
* Java ArrayList class is non synchronized.

when we talk about arrayList, I think we should consider about Genaric collection.
Now you will see what is genaric. 🙂

Before genaric is introduced we can store any type of objects in collection. It means non-generic. But in “genarics” , forces java programmer to   store specific type of objects.

Before genarics, here we have to do type casting.

List list = new ArrayList();
String s = (String) list.get(0);//typecasting

After genarics, here we don’t need to typecast the object.

List<String> list = new ArrayList<String>();
String s = list.get(0);

In generic collection, we specify the type in angular braces. Now ArrayList is forced to have only specified type of objects in it. If you try to add another type of object, it gives compile time error.


How to install xampp on ubuntu

Hi  Today my friend asked me how to install xampp on ubuntu. Ohhh I have installed it before but  I forgot it 😀  So I thought it is better to write it…. 😀

First go to below this link and download xampp instaler

Screenshot from 2016-05-24 14:52:44

Screenshot from 2016-05-24 14:59:51

Ok then we have to go to  .run file location and give permission for that file.

Screenshot from 2016-05-24 15:16:21

Then run installer file
run this command


then it will show this

Screenshot from 2016-05-24 15:45:35


Screenshot from 2016-05-24 15:48:17

Screenshot from 2016-05-24 15:49:00

Screenshot from 2016-05-24 15:50:51

OK Now we have installed xampp. 🙂 and then we have to run below command to start lampp

sudo  /opt/lampp/lampp  start

and to stop

sudo  /opt/lampp/lampp  stop

Screenshot from 2016-05-24 16:04:45

If there is any permission problem 😀 give permission
sudo chmod 777 htdocs

Screenshot from 2016-05-24 16:16:19

This worked for me 😀 thank you !!!!


How to install mobile partner in ubuntu

Hi guys today I found another small thing in Ubuntu 🙂 Actually It was told me by my friend Kalinga 🙂 Thanks bro..
Today I knew about how to install mobile partner in Ubuntu. So I am going to tell you too how to install modem-manager-gui

To add the PPA, run these commands in terminal: (now don’t ask me what is PPA 😀 search it )

sudo add-apt-repository ppa:linuxonly/modem+manager+gui
sudo apt-get update

Then run this command
sudo apt-get install modem-manager-gui

Ok i think now you have modem-manager-gui  in your ubuntu environment because It worked for me 🙂
Thank you !!!



What is the difference between Procedural Programming and OOP Programming ?

In Procedural Programming we use a list of instructions to tell the computer what to do and here we divide the program into small parts called functions. In PP, If you want a computer to do something, you should provide step-by-step instructions on how to do it and it follows top down apporach. It means Procedural Programming takes on applications by solving problems from the top of the code down to the bottom. The main issue in PP is that if a developer wants to edit a code he must edit every line of code that corresponds to the original change in the code.

Object-oriented Programming is a programming language that uses classes and objects to create models based on the real world environment. An object is a component of a program that knows how to perform certain actions and how to interact with other elements of the program and objects are the basic units in OOP. In OOP It is easy to edit and maintain the code. Also other developers can understand the program after development.

A method in OOP is like a procedure in PP and method is part of an object.In object-oriented programming, you organize your code by creating objects, and then you can give those objects properties and you can make them do certain things.

  • Object-oriented Programming uses methods and Procedural Programming uses procedures.
  • Object-oriented Programming uses objects where Procedural Programming uses records.
  • Object-oriented Programming uses classes where Procedural Programming uses modules
  • Object-oriented Programming uses messages where Procedural Programming uses procedure calls.
  • In PP, Most function uses Global data for sharing that can be accessed freely from function to function in the system and In OOP, data can not move easily from function to function,it can be kept public or private so we can control the access of data.
  • PP does not have any proper way for hiding data so it is less secure and OOP provides Data Hiding so provides more security.
  • PP follows Top Down approach and OOP follows Bottom Up approach.
  • In POP, Overloading is not possible and In OOP, overloading is possible in the form of Function Overloading and Operator Overloading.

I saw a simple example about PP & OOP when I searched  🙂


A simple way to compare both programming methods is to think of Object-oriented Programming as  learn to read picture book. As children see pictures of simple objects like a house or picture they know that throughout the book when they see a picture of the house it represents the word house. The children can then read through the book as words are substituted throughout the story with pictures.

In Object-oriented Programming the classes could represent the pictures in the learn to read books. A house could represent a class and anything the developer wants to have included to describe that house like the color, size, number of bathrooms etc.

In Procedural Programming the learn to read book would be words on the page without pictures to help guide the young learner through the book. If the story was changed in the beginning of the book it could disrupt or make the story later on in the book not make any sense. Although learning to read the book would make programming with Procedural Programming simple, it would make it difficult for other readers in the case of the book or programmers in the case of Procedural Programming to add to the story.


How to install google chrome on ubuntu

Ok get the terminal and again you have to only give some commands…..

First you have to give the link for chrome.

Screenshot from 2016-04-09 09:00:32

Ok now wait…. It is downloading…

Screenshot from 2016-04-09 09:03:21

After that enter below command…
sudo dpkg -i google-chrome*

Screenshot from 2016-04-09 09:07:51

Ok now you have installed chrome. But if it will give error try this force command.

sudo apt-get install -f

Screenshot from 2016-04-09 09:12:38

This steps worked for me. Try these and thank you….. 🙂


How to install sublime text-3 in ubuntu

Ok first get the terminal……

Screenshot from 2016-04-06 13:53:21

It is very easy.. now follow this commands…..

  • sudo add-apt-repository ppa:webupd8team/sublime-text-3
    now it will ask your password. so give it :D
    Then again you will have to press enter. wait....
    ok now enter below command.


  • sudo apt-get update

    wait and enter this command

  • sudo apt-get install sumblime-text-installer

    Ok now you have installed sublime text editor…..






Grub rescue error(no such a partition)

error: no such partition.
Entering rescue node...
grub rescue>_

Is this the error you get when you on your computer? Ok let’s try this……..

  • First type ls
    Then you can see like this output

(hd0) (hd0,1) (hd0,2) (hd0,3)  
 (hd0) (hd0,msdos1) (hd0,msdos2) (hd0,msdos3)…..

  • Then type this command…..

ls (hd0, msdos1)
When you’ll enter this command some times it’ll says. There is no such partion or some other error.
So you have  to enter     ls (hd0,msdos2) or
ls (hd0,msdos3) or
……………….. like this untill you get a success message 🙂

Ok now you have recognized the valid partion(msdos1/msdos2/msdos3..etc). After that you have to follow these steps.

set boot=(hd0,msdos5)
(In this command msdos5 is the partion which you have recognized as a valid one)

set prefix=(hd0,msdos5)/boot/grub

insmod normal


After entering this commands you can start your computer. This method worked for me 🙂