double x = 3; double y = -3; double theta = Math.atan2(y, x); System.out.println("Theta = " + theta);
double x = -5; double y = 5; double theta = Math.atan2(y, x); System.out.println("Theta = " + theta);Output: Theta = 2.356194490192345 In this example, we have x = -5 and y = 5. Calling atan2(y, x) returns the angle theta, which is 135 degrees (2.356194490192345 radians) relative to the x-axis. This function is part of the java.util package library in Java.