Java

1. 실행버튼 아래에 Run configuraions의 쓰임: 변수의 값을 지정할 때 사용자로부터 직접 입력받지 않아도 됩니다. configurations에 arguments에 변수의 값을 써 놓으면, 써놓은 순서대로 args 배열에 저장이 됩니다. 예를 들어, arguments에 "Pusan APT 507", "15.0" 이렇게 쓰고 Apply를 누르면 자동으로 args[0]에는 "Pusan APT 100"이, args[1]에는 "15.0"이 저장됩니다. 2. Public static void main(String[] args)할 때 이 args기 때문에 따로 선언할 필요 없습니다. 사용할 변수에 args를 넣어주면 됩니다. 예를 들어, id 변수와 bright 변수를 사용하고 싶으면, String i..
import javax.swing.JOptionPane; import org.opentutorials.iot.DimmingLights; import org.opentutorials.iot.Elevator; import org.opentutorials.iot.Lighting; import org.opentutorials.iot.Security; public class OkJavaGoInHomeInput { public static void main(String[] args) { String id = JOptionPane.showInputDialog("Enter a ID"); String bright = JOptionPane.showInputDialog("Enter a Bright level"); // El..
bug : 코드를 작성할 때 의도하지 않은 문제입니다. debug : 프로그래밍 과정 중에 발생하는 오류나 비정상적인 연산, 즉 버그를 찾고 수정하는 것입니다. debugging : 버그를 올바르게 잡는 행위입니다. debugger : 디버깅에 쓰이는 도구입니다. ※ 자세한 건 영상 참조 step1 : 프로그래밍을 멈춤 (double click -> break pointer) step2 : Debug 실행 버튼 click perspective (java -> debug 전환) step-over click시 한 명령어만 실행. 즉, debuger를 이용하면, 프로그램을 한줄한줄 실행가능 또한, 그 순간 어플리케이션 내 변수의 상태를 하나하나 체크 가능 step3 : 중간부분 자동실행 시 해당부분 줄번호 더..
Programming 프로젝트에 OkJavaGoInHome 클래스 생성할 때 package란에 자동으로 위치 지정돼 있으면 빈칸으로 만듭니다. import org.opentutorials.iot.Elevator; import org.opentutorials.iot.Lighting; import org.opentutorials.iot.Security; public class OkJavaGoInHome { public static void main(String[] args) { String id = "JAVA APT 507"; // Elevator call Elevator myElevator = new Elevator(id); myElevator.callForUp(1); // Security off Secu..
public class Program { public static void main(String[] args) { System.out.println(1); System.out.println(2); System.out.println(3); } }
public class Casting { public static void main(String[] args) { double a = 1.1; double b = 1; double b2 = (double) 1; System.out.println(b); //int c = 1.1; double d = 1.1; int e = (int) 1.1; System.out.println(e); // 1 to String String f = Integer.toString(1); System.out.println(f.getClass()); } } .getClass() : 데이터의 타입을 알려주는 함수입니다.
public class Letter { public static void main(String[] args) { String name = "leezche"; System.out.println("Hello, "+name+" ... "+name+" ... egoing ... bye"); double VAT = 10.0; System.out.println(VAT); } }
public class Variable { public static void main(String[] args) { int a = 1; // Number -> integer ... -2, -1 , 0, 1, 2 ... System.out.println(a); double b = 1.1; // real number -> double ... -2.0, -1.0, 0, 1.0, 2.0 ... System.out.println(b); String c = "Hello World"; System.out.println(c); } }
kms152000
'Java' 태그의 글 목록