생성자의 활용주로 멤버변수에 대한 기본값을 설정객체를 생성하는 것 만으로 멤버변수가 초기화 된다. 1234567891011121314151617181920212223242526class Book { String subject; String content; //생성자 Book(String subject){ this.subject = subject; this.content = "공부"; } //출력 void read(){ System.out.println("------- read 실행 -------"); System.out.println("subject : "+this.subject); System.out.println("content : "+this.content); }} public clas..
this란 자기자신을 의미하는 키워드 1234567891011121314151617public class Test { String name = "하하"; public void setName(){ String name; name = "호호"; System.out.println("name : "+name); System.out.println("this.name : "+this.name); //this 사용 } public static void main(String[] args) { Test t = new Test(); t.setName(); } } Colored by Color Scriptercs name : 호호this.name : 하하
재귀함수 재귀함수는 자기자신을 호출하는 함수이다. 단 사용 시 무한히 반복되는 재귀호출은 X 문제의 크기는 점점 작아져야한다. 꼭 재귀호출이 끝나는 종료 조건이 있어야한다. 장점 : 코드가 간결하고 오류 수정이 용이 단점 : 코드를 이해하기 어렵게 만들고 기억공간을 많이 요구 소스 123456789101112131415161718192021 public class test { int i = 0; public static void main(String[] args) { test(9); } public static void test (int i) { System.out.println(); if(i
.concat( "문장" ) ;- 문장을 붙여줌 .replace( '바꿀 단어', '단어' );- 단어를 바꿔 줌 (문장에 포함된 모든 단어) .substring( 초기위치, 끝위치);- 문장을 잘라 줌 (초기위치 ~ 끝위치 범위만 출력) .toUpperCase()- 소문자를 대문자로 바꿔 줌 예제) 123456789101112131415 String p = "A Barking dobg"; String s1,s2,s3,s4; System.out.println("문자열의 길이 = "+ p.length()); s1 = p.concat(" never Bites!"); s2 = p.replace('B', 'b'); s3 = p.substring(2, 5); s4 = p.toUpperCase(); System.o..
JAVA에서는 객체를 New 연산자로 선언하고 생성한다.Class 타입 변수명 = new 생성자 (); [예제 소스] 1234567//구조체 : 다른 타입의 변수들의 묶음 자료형//사용자 정의 자료형class Student{ int age; int score; String name;}cs123456789public class Stuent_Test { public static void main(String[] args) { Student s = new Student(); //우리가 만든 데이터 타입 s.age = 20; s.score = 100; s.name = "성연"; System.out.println(s.age + " / "+ s.score + " / " + s.name); }}Colored by C..
- Total
- Today
- Yesterday
- 음식
- nsis
- 안드로이드
- jdbc
- 생성
- jsp
- 어노테이션
- 스프링
- Controller
- Delete
- Create
- js
- Class
- 사용
- 종류
- 자바
- 연결
- synchronized
- Android
- Server
- 라이브러리
- mybatis
- iNT
- spring
- java
- 하기
- 클래스
- UTF-8
- Default
- mysql
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |