Hey guys, I have been struggling for so long to figure out  how to detect 2D collision in Java. I have looked at multiple videos on youtube and I have took the time to think about what each part means mathematically. I still can't seem to get it to work. I'm trying to build a simple pong game and I'm stuck on trying to get the ball to detect if its colliding with the paddle. Here's my collision code:

the x and y is the balls coordinates.

public void checkCollision(){
if (x <= player.getX() + player.getWidth() && (x >= player.getX()))
{
if((y + height <= player.getY()) && (y >= player.getY() + player.getHeight()))
{
System.out.println("collision");
}
}

if anyone could help me figure this out I would greatly appreciate it.