I'm new to Java and I stumbled upon this while testing some code. Why does Java pass in x (of data type long) into the function that takes in double parameters instead of the one with integer parameters. I would appreciate it if somebody could kindly explain to me why (Even though it might be an easy question to most of you!) Thank you in advance!
public class Hello {
public static void main (String [] args) {
long x=1;
System.out.println("Before calling the method, x is "+x);
increase(x);
System.out.println("After calling the method, x is "+x);
System.out.println();
double y=1;
System.out.println("Before calling the method, y is "+y);
increase(y);
System.out.println("After calling the method, y is "+y);
}
public static void increase(int p) {
p+=1;
System.out.println(" Inside the method is "+p);
}
public static void increase(double p) {
p+=2;
System.out.println(" Inside the method is "+p);
} }