Consume REST Web Service via Android

Lets say you have created an activity called

You need to import Async task to run a web service call.

import android.os.AsyncTask;

And inside the controller class you need to create sub class for async task. Below I have added that sub class.



Java Upcasting

When reference variable of a parent class refers to an object of child class then we call it upcasting.

Example is below.

Class Bank(){

Class ComBank extends Bank(){

Class BankModule(){
public static void main(String args[]){
Bank bank = new ComBank(); // This is the process of upcasting

Java Static Blocks, Variables and Methods

Static Member :-

What is a static member ? Static member is a member of a class that which is not interact or associate of  an instance of a class. This can be access without creating a object of a class. Moreover static members are being executed when class load in to the memory.  Further static members are accessible from any where and certain member is common for every instances. All objects use some instance of a static member.


Hash Map

HashMap is one of the most performing data structure in java collection framework. This provides constant time for both insertion and retrieval. This is used for large scale data since this is having high performance in insertion and retrieval. However this performance is depending on the two factors such as initial capacity and load factor. We can construct HashMap in four way and default constructor is having load factor is .75 and initial capacity as 16.


Singleton Design Pattern

This is the pattern which ensures there will be only one instance of a class in JVM and it can be accessed via globally. Generally this pattern is used to be on caching, logging, settings and configurations and so on.

Static class has below properties such as : –

  1. Static Member – this keeps the instance of class.
  2. Private constructor – this avoids creating multiple instances from this class.
  3. Static public method – the only one instance can be accessed via globally through this method.