function toRadians(degree) { return degree * Math.PI / 180 } function distance(latitude1, longitude1, latitude2, longitude2) { // R은 지구의 반지름, 단위는 km var R = 6371; var deltaLatitude = (latitude2 - latitude1).toRadians(); var deltaLongitude = (longitude2 - longitude1).toRadians(); latitude1 = latitude1.toRadians(),latitude2 = latitude2.toRadians(); var a = Math.sin(deltaLatitude / 2) * Math.sin(deltaLatitude / 2) + Math.cos(latitude1) * Math.cos(latitude2) * Math.sin(deltaLongitude / 2) * Math.sin(deltaLongitude / 2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); var d = R * c; return d; }
미등록2011. 8. 4. 10:15
JAVA2011. 8. 1. 11:27
예약어 new : 클래스를 메모리에 할당하여 해당 클래스를 사용할 수 있게 한다.
exam
exam
class PowerSwitch { // PowerSwitch 클래스의 맴버변수 power선언. private boolean power; // 맴버변수 power를 리턴하는 getPower변수. public boolean getPower() { return power; } // 맴버변수 power에 값을 입력 public void setPower(boolean button) { power = button; } public static void main(String[] args) { // PowerSwitch클래스를 메모리에 할당하여 사용가능한 상태로 만든다. PowerSwitch powerswitch = new PowerSwitch(); // setPower변수에 ture값을 세팅하면 power의 값이 true로 바뀐다. powerswitch.setPower(true); System.out.println(powerswitch.getPower()); // setPower변수에 false값을 세팅하면 power의 값이 false로 바뀐다. powerswitch.setPower(false); System.out.println(powerswitch.getPower()); } }
'JAVA' 카테고리의 다른 글
ResultSet의 Row를 Map로 변환후 List에 저장 (1) | 2011.10.25 |
---|---|
2진수 10진수로 변환 (0) | 2010.09.09 |
10진수 2진수,8진수 변환 (0) | 2010.09.09 |
java systeminfo파일로 정보읽기 (0) | 2010.09.08 |
JAVA 시스템 환경읽어오기 (0) | 2010.09.08 |
카테고리 없음2010. 11. 16. 16:20