본문 바로가기

전체 글14

call by reference의 의미 자바에는 call by reference라는 개념이 없음 c++ 에만 존재하는 개념 자바에서 오해하는 call by references는 call by value이다 call by value는 variable, address 2가지로 분류됨 우리가 착각하는 부분이 call by value의 address를 받는것임 2022. 10. 7.
enum 사용시 기억할 점 enum은 열거형 함수로 상수 전용 클래스로 생각하면 된다 상수하나 객체 모두 public static final이다 클래스와 동일한 개념으로 enum { } 안에 상수를 나열하면 끝이다. 그리고 다른 클래스처럼 생성자도 만들 수 있음 enum AuthMethod{ FIN, FINGER, PATTERN, FACE; AuthMethod() {} } 2022. 10. 7.
조건문, 랜덤값,반복문 실수하는 부분들 switch~case문에서 break;를 절대 까먹지말자!!! break;가 없는 경우 case를 실행하고 그 밑에 있는 case까지 전부 진행하게 된다!! 랜덤값을 사용할 때는 아래와 같이 import를 해줘야 함 import java.util.Random; public class InputTest { public static void main(String[] args) { Random input = new Random(); System.out.println( input.nextInt() ); // 1483266798 (int 표현범위 사이값) System.out.println( input.nextInt(10) ); // 1 (0 2022. 9. 30.
입출력 메소드 / 자료형 변환 / 연산자에서 자주쓰는 것 입력시 import java.util.Scanner; public class InputString { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String input = sc.nextLine(); >>> nextLine으로 입력 받으면 문자열 + \n 까지 같이 진행됨 } } 문자열 이외는 next + 자료형 을 입력하면 됨 출력시 System.out.print(); >>> 문장 마지막에 엔터를 포함하지 않고 출력 System.out.println(); >>> 문장 마지막에 엔터를 포함하여 출력 System.out.printf(); >>> 포맷에 맞춰 문장을 출력하는 함수 다양한 출력 형태 출력 서식 지시자.. 2022. 9. 30.