Error in using the java Math class in an array


I’m trying to print the largest number of 2 numbers using java Math but I keep getting an error. I’m new to Java and I would really appreciate the help.


public class Math {
  public static void main(String[] args) {
    System.out.println(Math.max(5, 10));  

Error: error: cannot find symbol
    System.out.println(Math.max(5, 10));
  symbol:   method max(int,int)
  location: class Math
1 error


The problem is that you called your class Math as well. The compiler wants to find the method max in your own class.

To fix that, give your class another name.

Source: stackoverflow