🗣️ Programming Language

MyArrayList.java public class MyArrayList { int initCapacity = 10; int[] elementData; int size; // # of data added int currentCapacity; int result; public MyArrayList() { elementData = new int[initCapacity]; size=0; currentCapacity = initCapacity; } public int get(int index) { return elementData[index]; } public void add(int data) { if(size == currentCapacity) { // array size 확대
Scanner: java.util 패키지 내에 존재하는 자바의 기본 입력 클래스 Method of Class Scanner Type(타입) Method(메소드) Description(설명) byte nextByte(), nextByte(int radix) Scans the next token of the input as abyte. short nextShort(), nextShort(int radix) Scans the next token of the input as a short. int nextInt(), nextInt(int radix) Scans the next token of the input as an int. long nextLong(), nextLobg(int radix) Scans the..
조건문의 종류 if 문 switch 문 삼항 연산자 삼항연산자 문법: 조건식에 따른 반환값을 지정 (조건식) ? 반환값1 : 반환값2; if-else문 public class Test { public static void main(String[] args){ boolean darkMode = false; String currentMode = ""; if(darkMode){ currentMode = "darkMode"; }else{ currentMode = "whiteMode"; } System.out.println(currentMode) // "whiteMode" } } 삼항 연산자 public class Test { public static void main(String[] args){ boolean ..
배열 요소에 접근하기 배열 요소 갯수 확인하기 배열 뒷부분에 요소 추가하기 배열 특정 위치에 요소 추가하기 배열 요소 제거하기 index.html
kimgoat
'🗣️ Programming Language' 카테고리의 글 목록