How to scroll the page to the element i wanted in Java

There A/B/C is on the current screen, Then I want to swipe to the D and click it
A
B
C

D
E
F

I tried
driver.scrollTo(“D”);
driver.scrollToExact(“D”);

Methods do not scroll to required element , but scroll to end of page

try

Dimension test = DRIVER.manage().window().getSize();

starty = test.getHeight; //y coordinate for the bottom of the screen

endy = test.getHeight/2; //y coordinate for middle of the screen

startx = test.getWidth/2;

endx = startx;

WebElement itemToScrollTo = driver.findelement(By.id(" "));

do{

driver.swipe(startx, starty, endx, endy, duration)

}while(!itemToScrollTo.isDisplayed)

The above code swipes upwards from the bottom of the screen to the middle until the item from the bottom of the screen becomes visible.

You need to modify the code to suit your needs scrollTo is inconsistent.