How can I drag an element from one location to another in Java?

In Java, how can I move an element from one position to another?

Hi Dipen,

User need to use action class of selenium where user have to pass source location and destination location which means the locators like :

//Element that need to be drop
WebElement From=driver.findElement(By.xpath(XPATH_OF_THE_SOURCE_LOCATOR));

        //Element on which need to drop.
        WebElement To=driver.findElement(By.xpath(XPATH_OF_THE_DESTINATION_LOCATOR));

        //Using Action class for drag and drop.
        Actions act=new Actions(driver);

        //Dragged and dropped.
        act.dragAndDrop(From, To).build().perform();