반응형 전체 글34 10171_역슬래쉬 출력 역슬래쉬 : \\ (앞에 \붙이기) public class Main { public static void main(String[] args) { System.out.println("\\ /\\"); System.out.println(" ) ( ')"); System.out.println("( / )"); System.out.println(" \\(__)|"); } } 2021. 8. 17. 10718_for문 출력 public class Main{ public static void main(String[] args) { for (int i =0; i 2021. 8. 17. 2557_hello world 출력 public class Main{ public static void main(String args[]){ System.out.print("Hello World!"); } } 2021. 8. 17. Kotlin 기본 정리 1. 변수 선언 val : 값 변경 x var : 값 변경 o 2. null 사용가능 ? : 변수유형의 접미사로 지정하여 변수 nullable 지정 가능. val name : String? = null // ?가 없다면 오류 *자바에서 null값에 대해 메서드 호출시 비정상 종료. (NullPointerException) 3. 조건부 if-else문 val name : String = if (count == 5){ "apple" }else if (count >3){ "orange" }else{ "grape" } when val name = when { count == 5 -> "apple" count >3 -> "orange" else -> "grape" } null 값 참조 검사 val name: St.. 2021. 8. 12. 이전 1 ··· 4 5 6 7 8 9 다음 반응형