API Integer 안에있는 max() 메소드를 보면 Math.max() 를 호출해서 최대값을 리턴한다 라고 되어있는데요.
Integer.max(); 를 썼을때는 컴파일 에러가 나와서
Math.max(); 로 다 바꿔서 쓰니깐 맞다고 뜨네요.
Integer.max()를 썼을때 콘솔에서는 잘 돌아갔습니다.
이건 왜 그런건가요???
Main.java:17: error: cannot find symbol max = Integer.max(a.length(), b.length()); ^ symbol: method max(int,int) location: class IntegerMain.java:18: error: cannot find symbol max = Integer.max(max,c.length()); ^ symbol: method max(int,int) location: class IntegerMain.java:19: error: cannot find symbol max = Integer.max(max,d.length()); ^ symbol: method max(int,int) location: class IntegerMain.java:20: error: cannot find symbol max = Integer.max(max,e.length()); ^ symbol: method max(int,int) location: class Integer4 errors
API 버전 문제일겁니다.
https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#max-int-int-
여기 보시면 1.8 때 도입됐다는 걸 알 수 있습니다.
이 사이트에서는 1.7 로 채점을 하고요.
댓글을 작성하려면 로그인해야 합니다.
bbbbbbb 7년 전 1
API Integer 안에있는 max() 메소드를 보면 Math.max() 를 호출해서 최대값을 리턴한다 라고 되어있는데요.
Integer.max(); 를 썼을때는 컴파일 에러가 나와서
Math.max(); 로 다 바꿔서 쓰니깐 맞다고 뜨네요.
Integer.max()를 썼을때 콘솔에서는 잘 돌아갔습니다.
이건 왜 그런건가요???
Main.java:17: error: cannot find symbol
max = Integer.max(a.length(), b.length());
^
symbol: method max(int,int)
location: class Integer
Main.java:18: error: cannot find symbol
max = Integer.max(max,c.length());
^
symbol: method max(int,int)
location: class Integer
Main.java:19: error: cannot find symbol
max = Integer.max(max,d.length());
^
symbol: method max(int,int)
location: class Integer
Main.java:20: error: cannot find symbol
max = Integer.max(max,e.length());
^
symbol: method max(int,int)
location: class Integer
4 errors