자바

    [Java Study] 인텔리제이(intellij) 디버거 사용하기

    [Java Study] 인텔리제이(intellij) 디버거 사용하기

    버그를 잡기 위해, 혹은 프로그램 흐름을 살펴보며 데이터 값을 확인하기 위한 디버거 기능을 사용해보자. 디버그 모드에 진입하는 것은 Run -> Debug...로 시작한다. 줄 번호 옆에 마우스 왼쪽 버튼을 누름으로써 Break Point를 지정할 수 있다. 디버깅을 진행할 때 프로그램은 이 곳에서 멈춘다. 하단에 위치한 디버깅 툴에서는 다음 줄으로 넘기기, 다음 Break Point가 있는 곳 까지 프로그램 진행, 등등... 여러가지 기능들이 있고, 프로그램이 실행되며 데이터가 저장되는 구조, 어떤 변수에 무엇이 들어있는지 등등 구체적인 내부 과정을 알 수 있다.

    [Java Study] 간단한 IoT 구현하기

    [Java Study] 간단한 IoT 구현하기

    import org.opentutorials.iot.Elevator; import org.opentutorials.iot.Lighting; import org.opentutorials.iot.Security; public class OkJavaGoingHome { public static void main(String[] args){ String id = "JAVA APT 507"; // Elevator call Elevator myElevator = new Elevator(id); myElevator.callForUp(1); // Security off Security mySecurity = new Security(id); mySecurity.off(); //Light on Lighting hallLa..

    [Java Study] 데이터 타입의 변환 (Casting)

    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; // error! double -> int impossible double d = 1.1; int e = (int) 1.1; System.out.println(e); String strI = Integer.toString(1); System.out.println(strI.getClass()); } } 1.0 1 class java.lang.String 데이터 타입의 변환 (Casting)에 대하여 알아보았다. 주의할 점 몇가지만 ..

    [Java Study] 변수의 정의

    public class main { public static void main(String[] args) { int a = 1; //Number -> integer System.out.println(a); double b = 1.1; //real number -> double System.out.println(b); String c = "Hello world"; System.out.println(c); } } 1 1.1 Hello world 변수를 이용하여 데이터를 다룰 때 기본적인 자료형에 대해 알아보았다. 이건 C언어의 방법과 동일했다. 문득 main 함수를 선언할때 적어주는 String[] args 는 무슨 의미를 담고 있을지 궁금해졌다.. 구글링을 좀 해보니.. tistory mozi 님의 게시글..

    [Java Study] 문자열 replace 함수

    public class main { public static void main(String[] args) { System.out.println("Hello World".length()); System.out.println("Hello, [[choi]]... bye.".replace("[[choi]]", "kim")); } } 11 Hello, kim... bye 문자열로 표현할 때 사용할 수 있는 length 함수와 replace 함수에 대하여 실습을 진행 해 보았다. C언어는 이런 함수들이 특정 헤더에 들어있어 사용이 필요할 때마다 찾아봐야 하는 번거로움이 있었지만 자바는 기본적으로 제공되는 다양한 함수들이 있는 듯 했다.

    [Java Study] 문자열의 표현

    public class main { public static void main(String[] args) { //String, Character System.out.println("Hello, world!"); //String 문자열 Character들의 집합체 System.out.println('H'); //Character 문자 하나 System.out.println("H"); System.out.println("Hello" +"world!"); System.out.println("Hello \nworld"); //New line System.out.println("Hello \"world\""); //Hello "world" } } Hello, world! H H Helloworld! Hello w..

    [Java Study] 숫자의 연산

    public class Number { public static void main(String[] args){ //Operator System.out.println(6+2); //8 System.out.println(6-2); //4 System.out.println(6*2); //12 System.out.println(6/2); //3 System.out.println(Math.PI); System.out.println(Math.floor(Math.PI)); //내림 System.out.println(Math.ceil(Math.PI)); //올림 } } 8 4 12 3 3.141592653589793 3.0 4.0 간단한 숫자의 연산을 프로그래밍 해 보았다. C언어에서의 math.h 기능이 Math. ..

    [Java Study] java 데이터 타입(숫자, 문자)

    public class Data_and_Operation { public static void main(String[] args){ System.out.println(6); //Number System.out.println("six"); //String System.out.println("6"); //String 6 System.out.println(6+6); //12 더하기연산자 System.out.println("6"+"6"); //66 결합연산자 System.out.println(6*6); //36 // System.out.println("6"*"6"); System.out.println("1111".length()); // System.out.println(1111.length()); //에러! ..

    [Java Study] Hello, Java!! 출력하기

    public class HelloJava { public static void main(String[] args){ System.out.println("Hello, Java!!"); } } Hello, Java!! 기본적인 구조를 알 수 있다. class라는 큰 틀 안에 void형으로 선언된 main 함수 안의 코드가 동작한다.

    [개발환경] 자바 설치 방법 (개발환경 세팅하기, java -version 안될 때)

    [개발환경] 자바 설치 방법 (개발환경 세팅하기, java -version 안될 때)

    java개발을 처음 시작하는 분들(나를 포함)을 위하여 처음부터 차근차근 개발 환경을 세팅해 볼까 한다. 우선 나의 경우 window10을 사용하고 있으므로 이를 기준으로 설명하겠다. 키보드에서 window키와 R키를 동시에 눌러 나오는 실행창에 cmd 입력 -> 확인 cmd 창에 "java -version" 입력 후 enter. 나는 java가 설치되지 않았기 때문에 다음과 같은 출력이 나온다. 자바 버전이 출력되는 이들은 자바 설치를 따로 진행할 필요가 없다. https://www.oracle.com/java/technologies/downloads/#jdk18-windows 위 링크에서 64bit 설치를 진행하였다. (next -> next -> close) 이후 cmd 창에서 java -versi..