일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- FIle
- Spinner
- Android
- SQL
- 오버라이드
- sub query
- Spring
- 왕초보
- 함수
- 상속
- degit
- webpack
- java#왕초보
- kotlin
- 버전일치
- 숫자
- 시큐어코딩
- java
- 미니게임
- 게시판
- 스프링
- React
- 안드로이드
- parcel
- 스타일보험
- snowpack
- 코틀린
- 답글
- git
- 쿠키
- Today
- Total
목록Coding/Java (44)
YSHUSH

public class MainClass { public static void main(String[] args) { /* ArrayList : 검색, 대입 LinkedList : 실시간 추가 / 삭제 처리가 빠르다 */ LinkedList list = new LinkedList(); list.add("Tigers"); list.add(new String("Lions")); list.add("Giants"); for (String s : list) { System.out.println(s); } list.addFirst("Bears"); // = list.add(0, "Bears"); // ArrayList에는 없음 ArrayList alist = new ArrayList(list); for (Strin..

MainClass public class MainClass { public static void main(String[] args) { /* Collection : 수집 List : 목록 ArrayList 배열처럼 사용할 수 있는 목록 선형구조O-O-O-O-O-O-O-O- 검색 속도가 우수하다. index로 접근한다. LinkedList 추가/삭제의 속도가 우수하다. - 게임 */ ArrayList arrList = new ArrayList(); //List arrList = new ArrayList(); // 추가 arrList.add(111);// [0] Integer in = new Integer(222);// [1] arrList.add(in); arrList.add(new Integer(333)..

public class MainClass { public static void main(String[] args) { /* Collection : 수집 List : 목록 ArrayList 배열처럼 사용할 수 있는 목록 선형구조O-O-O-O-O-O- 검색속도가 우수하다. index로 접근한다. LinkedList 배열처럼 사용할 수 있는 목록 선형구조O-O-O-O-O-O- 추가/삭제가 속도가 우수하다. - 게임 */ ArrayList arrList = new ArrayList();// 서류철 빈통이라고 생각하면 됨 // 클래스로 되어있음 //List arrList = new ArrayList(); //인터페이스로 되어있음 // 추가 arrList.add(111);// [0] Integer in = new ..

˙ Generic == template(형태) - 자료형 변수 - 같은 클래스에서 다양한 자료형을 사용하고 싶은 경우, 설정하는 요소 Box box = new Box( 123 ); box.setTemp( 234 ); System.out.println(box.getTemp()); Box sbox = new Box( "hello" ); sbox.setTemp("world"); System.out.println(sbox.getTemp()); //Box tbox = new Box(1);일반 자료형은 사용 못함 BoxMap bmap = new BoxMap(1001, "홍길동"); System.out.println(bmap.getKey()); System.out.println(bmap.getValue()); Box..

Main class public class MainClass { public static void main(String[] args) { /* static : 정적 동적(dynamic) variable method */ MyClass cls = new MyClass(); cls.func(); cls.func(); cls.func(); MyClass mycls = new MyClass(); mycls.func(); mycls.func(); //mycls.staticNumber= 12; MyClass.staticNumber = 14;// 이렇게 접근해서 사용하는 경우가 많음 mycls.func(); // 메소드 YouClass yc = new YouClass(); yc.memberMethod();// 멤버메..

public class MainClass { public static void main(String[] args) { /* final == const define variable class method */ final int number = 10;// 변수 -> 상수(지정된 수, 변할 수 없는수) // 대입용도(특정 숫자를 정해놓고 대입만 할 때) final int MEMBERMAX = 20;// val var -> kotlin int num = number; int num1 = MEMBERMAX;// final로 인해 상수로 된 경우 보통 모두 대문자로 쓴다. if(num > 0 && num < MEMBERMAX) { } } } /*final*/ class Parent{// 클래스 앞에 final이 추..

Main class public class MainClass { public static void main(String[] args) { // 8. NameCard namecard = new NameCard("홍길동", "123-4567", "hgd@naver.com"); // 9. namecard.setPrintCard(new PrintNameCard()); namecard.print(); // 11. namecard.setPrintCard(new PrintNamePhoneCard()); namecard.print(); } } Print interface public interface PrintInterface { // 3. public void print(NameCard nc); } Name card..

Main class /* 추상 메소드'만'을 포함하는 형태(template) 멤버변수를 포함할 수 없다 일반 메소드도 포함할 수 없다. 상속받은 후에 메소드를 정의한 후에 사용할 수 있다. class의 사양을 파악할 수 있는 용도로 많이 사용한다. 확장성(다형성)에서 사용 전체를 묶는다(부모클래스 격이다) 다중 상속이 가능하다 */ public class MainClass { public static void main(String[] args) { //MyInterface myi = new MyInterface();-> 안됨 MyClass mycls = new MyClass(); mycls.method(); MyClass myi = new MyClass(); myi.method(); /* MyInterf..

Main class /* Abstract class : 추상 클래스 추상 메소드를 하나이상 포함하고 있는 클래스 일반 메소드를 포함하고 있다. 멤버 변수도 선언할 수 있다. Abstract method : 내용(처리)은 없고 prototype(매개변수, 리턴값)만 선언되어 있는 메소드 public void method(char c, int i){ process } public abstract void method(char c, int i); */ public class MainClass { public static void main(String[] args) { // AbstractClass ac = new AbstractClass(); 생성안됨 MyClass mycls = new MyClass(); m..

MainClass public class MainClass { public static void main(String[] args) { // 자식 클래스의 객체를 총 10개의 객체를 생성 ChildOne arrOne[] = new ChildOne[10]; ChildTwo arrTwo[] = new ChildTwo[10]; /* String name = ""; if(name.equals("one")) { }else { arrOne[0] = new ChildOne(); arrTwo[0] = new ChildTwo(); arrTwo[1] = new ChildTwo(); arrOne[1] = new ChildOne(); arrOne[2] = new ChildOne(); arrOne[3] = new ChildOn..