일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- layout
- mybatis
- 전화걸기
- JSP
- 메서드
- 어노테이션
- OGNL
- 에러페이지
- 클래스
- 기본
- struts2
- 이클립스
- Eclips
- 오버로딩
- HTML
- 배열
- 예외처리
- Spring
- Graphic
- 국제화
- paint
- JavaScript
- Java
- 안드로이드
- 생성자
- AWT
- Android
- 메소드
- oracle
- Menu
- Today
- Total
목록자바 (201)
note
public class BreakEx1 {//break label문 public static void main(String[] args){ exit_for : //label 빠져나갈곳 지정 for(int i = 0 ; i < 3 ; i++){ for(int j = 0; j < 5; j++){ if(j == 3){ break exit_for; //지정된곳으로 빠져나감 } System.out.println("i값:"+i+", j값"+j); } } } } i값:0, j값0 i값:0, j값1 i값:0, j값2
public class F01 {//break문 사용 public static void main (String[] args){ int n; for(n=1; n 1 2 3 4 5 6 7 8 9 10 1 2
public class Do_WhileEx1 {//do while문 public static void main(String[] args){ int su = 0; String str = "Java DoublePlus"; do{ System.out.println(str); }while(su++ < 5); //(주의) semicolon 생략시 오류 System.out.println("\n"); su = 0; while(su++ Java DoublePlus Java DoublePlus Java DoublePlus Java DoublePlus Java DoublePlus Java DoublePlus Java DoublePlus Java DoublePlus Java DoublePlus Java DoublePlus ..
기본 public class While01 {//while 문 public static void main(String[] args){ int i; for(i=1; i for문과 다르게 조건식만 while문은 들어가 있다 for문과 while은 항상 무한루프를 염두해둬야한다 1 2 3 4 5 ----------------- 1 2 3 4 5 public class While02 {//while문2 public static void main(String[] args){ int i=1; //초기식 while(i++> 2, 3, 4, ----------- >> 1, 2, 3, 4, 5, ----------- >> while문으로 1부터 10사이의 짝수의 합구하기 public class While04 {//whi..
public class For02 {//for문 public static void main(String[] args){ int i; //변수 선언 // 초기식 조건식 증감식 변수선언을 여기서 하면은 for문내에서만작동 // 하기 때문에 위에서 선언함 for(i=1; i 1 2 3 4 ---> 5 변수 호출 영역 int a =3 for(int i =4) i호출 가능 a호출가능 i호출 불가 public class For06 {//for문 public static void main(String[] arg){ int i; //제어변수 선언 int total =0; //합을 누적할 변수 total을 선언하고0으로초기화 for(i=1; i 2단 출력 public class For04 {//for문으로 2단출력 pu..
public class Switch01 {//Switch문 public static void main(String[] args){ java.util.Scanner input= new java.util.Scanner(System.in); System.out.print("정수 입력 : "); int a = input.nextInt(); switch(a){ case 9 : System.out.println("A ");break; case 8 : System.out.println("B ");break; case 7 : System.out.println("C ");break; case 6 : System.out.println("D ");break; default : System.out.println("F ");/..
public class If01 {//if 문 public static void main(String[] args){ int num; //변수의 선언 num = -5; //변수 초기화 if(num >")..
public class Opr09 {//비트 단위 논리 연산자 public static void main(String[] args){ int a=12; // 8+4 =2³ + 2² // 128 64 32 16 8 4 2 1 // 0 0 0 0 1 1 0 0 //12 int b=20; // 16+4=2⁴ + 2² // 128 64 32 16 8 4 2 1 // 0 0 0 1 0 1 0 0 // 20 int c; c = a & b; // 비트 단위 값이 둘다 1일때만 1 // 128 64 32 16 8 4 2 1 // 0 0 0 0 1 1 0 0 // 0 0 0 1 0 1 0 0 // 0 0 0 0 0 1 0 0 // 값 4 System.out.println(a + " & "+ b + " -> " + c);..
public class OperEx06 { public static void main(String[] args){ int a = 5; int b = 7; //대입 연산자 a+=b; //a = a + b System.out.println("a = " + a); a-=b; //a = a - b System.out.println("a = " + a); a*=b; //a = a * b System.out.println("a = " + a); a/=b; // a = a / b System.out.println("a = " + a); a%=b; //a = a % b System.out.println("a = " + a); } } a = 12 a = 5 a = 35 a = 5 a = 5
public class Opr06 { public static void main(String[] args){ char ch='b'; //문자 변수 선언 //아스키 코드 98 String s; //대문자인지 판단한 결과를 저장할 문자열 변수선언 s = (ch>='A' && ch b=>대문자 아님
public class Opr04 {//논리 연산자와 조건 연산자 활용하기 public static void main(String[] args){ int a=29; String s="몰라"; s = (a>=10 && a 29 => 10대 아님
public class Opr03 { public static void main(String[] args){ int a=5, b=10; int max=a; //최대값으르 저장할 변수 선언 // 조건식 참값 거짓값 //조건식? 수식1 : 수식2 //조건식에 참이면 수식1 실행 거짓이면 수식2실행 max = a>b ? a : b; System.out.println("max = "+ max); } } max = 10
public class OperFx02 { public static void main(String[] args){ //증감연산자, 비교연산자, 논리연산자 int a,b; a = b = 10; boolean c = a++ >= ++b && ++a > b++; //10 11 // false System.out.println(a+","+b); //11, 11 System.out.println("변수 c의 값 :"+c); //false int d,e; d = e = 10; boolean f = ++d > e++ || d++ >= ++e; //11 10 11 12 // 앞문장만 실행됨 System.out.println(d+","+e); //11 ,11 System.out.println("변수의 f의 값:"+f);..
public class OperatorEx22 { public static void main(String[] args){ int a = 10; float b = 10.0f; if(a ==b){//int -> float 자동형변환 //10 -> 10.0f //10.0f == 10.0f System.out.println("10과 10.0f는 같다."); } char c = '0'; //아스키코드 48을 의미함 int d = 0; if(c != d){ //char -> int 자동형변환 //'0' -> 48 // 48 != 0 System.out.println("'0'과 0은 같지 않다."); } char e = 'A'; //아스키코드 65 int f = 65; if(e == f){ // char -> int..
public class Opr07 { public static void main(String[] args){ int a=10, b=10; System.out.println("====증가 연산자===="); //선행처리 System.out.println(++a); //후행처리 System.out.println(b++); System.out.println(b); int c=20, d=20; System.out.println("====감소 연산자===="); //선행처리 System.out.println(--c); //후행처리 System.out.println(d--); System.out.println(d); } } ====증가 연산자==== 11 10 11 ====감소 연산자==== 19 20 19
public class Opr02 { public static void main(String[] args){ int a=10, b=4; boolean test; test=a>b; System.out.println(a + ">" + b + " = " + test); test=a 10>4 = true 10
public class CastEx { public static void main(String[] args){ //====프로모션 (자동 형변환) ====// //더 큰 자료형으로 승격이 일어나는 형태, //정보의 손실이 전혀 없으며 자동적으로 발생 byte b1 = 127; byte b2 = 127; int b3 = b1 + b2; //32bit 미만의 자료형(byte)연산시 //32bit(int)로 승격 short s1 = 123; short s2 = 123; int s3 = s1 + s2; //32bit 미만의 자료형(byte)연산시 //32bit(int)로 승격 int in1 = 234; long lg = in1; // int->long 자동 형변환 int in2 = 1234; long lg2 =..
public class VariableEx {// 클래스 시작 //클래스명 public static void main(String[] args){//메소드 시작 int num; //변수 선언 num = 17; // 변수의 초기화 System.out.println(num);//호출,실행 final int COUNT = 30; // 상수 , //COUNT = 50; //상수는 프로그램 종료때까지 변하지 //않음 System.out.println(COUNT); int number; //변수선언 //변수 선언 후에 변수 초기화를 해야 출력또는 연산 가능 //System.out.println(number); }//메소드 끝 }//클래스 끝 17 30
public class VariableTypes { public static void main(String[] args){ //1.논리형(true, false) System.out.println("=====논리형====="); boolean b = true; //boolean b = 1; // 불허 System.out.println("b= " + b);//+는 연결해주는 부분 //2.문자형 (크기 : 2byte, 표현범위 : 0 ~ 65,535) //다국어 처리를 위한 유니코드 (uniocode)방식 System.out.println("=====문자형====="); char c1 = 'A'; //내부적으로는 아스키 코드 65에 해당 char c2 = 65; //A에 해당하는 아스키 코드값 65 char ..
식별자 프로그래머가 특별히 의미를 부여하는 단어 변수,메서드(함수),클래스의 이름등을 부른다 예약어 자바에서 미리 정의하고 의미를 부여한 단어 예약어는 중복될 수 없습니다 식별자와 Ex. int,char,class,if,else,witch,for,while,break 클래스 클래스를 선언후 클래스를 객체화 하여 프로그램을 작성합니다 클래스를 선언하기 위해 class란 예악어를 제공함 class는 자료의 추상화 하여 사용자 정의 자료형으로 구현하고자합니다 우리가 만드는 파일이 하나의 그릇이라고 하면은 최소한의 그릇 위에 내용들을 담기 위한것 형식 class 이름{내용} 이름 과 파일 이름은 같다(확장자 제외.java) 추가 내용 2월 16일 사실상 클래스는 객체지향을 표현하기 위한 가장 적절한 방법이라 생..