목록언어 (25)
DevYoon
Java 1️⃣ 거듭제곱 Math.pow() 사용 Math.pow(5, 2) ➡️ 5의 2제곱2️⃣ 형변환 실수 ➡️ 정수 (int) 변환할 실수 (long) 변환할 실수 int와 long의 차이? / int long bit 32bit 64bit byte 4byte 8byte 메모리 long보다 적게 사용 int보다 많이 사용 double과 float 차이? / float double bit 32bit 64bit byte 4byte 8byte 유효자릿수 7자리 15~16자리 높은 정밀도가 필요하다면 float보다는 double 사용 3️⃣ format String.format() 사용 public class Main { public static void main(String[] args) { int q ..
변수 public class Variable { public static void main(String[] args) { int a = 1; // 정수 = int(integer) System.out.println(a); double b = 1.5; // 실수 = double System.out.println(b); String c = "Hello Java"; // 문자 = String System.out.println(c); } } 1️⃣ 변수 만드는 법 정수 int 변수명 = 정수; 실수 double 변수명 = 실수; 문자열 String 변수명 = "문자"; 💭 실수는 float 아니고 double, 문자열은 string 아니고 String!
문자열 다루기 public class Stringapp { public static void main(String[] args) { System.out.println("Hello World"); // String System.out.println('H'); // Character System.out.println("H"); // 오류 X System.out.println("Hello " + "World"); // 이클립스의 개입 // new line System.out.println("Hello \nWorld"); // 줄바꿈 = \n // escape System.out.println("Hello \"World\""); // Hello "World" \뒤의 따옴표는 일반 문자열 } }1️..
숫자와 연산 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)); // floor = 내림 System.out.println(Math.ceil(Math.PI)); // ceil = 올림 } }1️⃣ 파일 쉽게 만들기 New ➡️ Class 2️⃣ 단축어 RUN = Ctrl+F11 3️⃣ M..
데이터와 연산 public class study //classname { public static void main(String[] args) { System.out.println("Hello World!"); } } study ➡️ 파일명과 동일해야 한다 ex) Datatype.java ➡️ public class Datatype { } "Hello World" ➡️ 'Hello world'는 동작하지 않음 큰 따옴표(") : 문자열(String)을 감싸는 기호, 즉 문자 여러 개 입력 작은 따옴표(') : 문자(Character)를 감싸는 기호, 즉 문자 하나만 입력 public class study { public static void main(String[] args) { S..