일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 클래스
- 어노테이션
- 생성자
- struts2
- mybatis
- 기본
- AWT
- HTML
- layout
- OGNL
- 안드로이드
- JSP
- 메소드
- Android
- Eclips
- 국제화
- 배열
- Java
- 전화걸기
- Menu
- 예외처리
- 에러페이지
- paint
- 오버로딩
- 메서드
- 이클립스
- Graphic
- JavaScript
- Spring
- oracle
- Today
- Total
목록전체 글 (572)
note
public class MethodEx { //멤버 메소드 public int sum(int a, int b){ //지역 변수 : 메소드 영역 또는 제어문 영역에서만 호출가능하도록 //선언한 변수 //public : 접근 제한자(지정자) //int : 반환 타입 //sum : 메소드명 //(int a, int b) : 인자 int result = a+b; //연산 return result; //반환값 } public void print(int a, int b){ //void : 반환하는 데이터가 없을때 void명시(빈) int result = a + b; System.out.println("result2 : "+ result); return; //일반적으로 생략 } //메인 메소드 public stati..
class Tv{ //부 클래스에는 public을 붙일 수 없다 //멤버 필드 String color; //색상(컬러/흑백) boolean power; //전원상태(on/off) int channel; } public class TvTest { public static void main(String[] args){ //객체 선언, 객체 생성 Tv t = new Tv(); //Tv : 참조자료형 //t : 참조변수(객체의 주소(reference)저장) //new : 객체 생성를 생성하도록 명명하는 연산자 System.out.println(t.color); System.out.println(t.power); System.out.println(t.channel); //멤버변수에 데이터 할당 t.color = ..
public class Score3 {//2차 배열로 성적 생성 public static void main(String[] args){ java.util.Scanner input=new java.util.Scanner(System.in); String[] subname = {"국어","영어","수학"}; int[][] sub = new int[3][subname.length + 1]; //0첫번째사람1두번째사람2세번째사람 float[] avg = new float[3]; //3명에 대한 각각 평균값 저장 for(int k =0; k < sub.length; k++){ for(int i = 0; i 100); sub[k][sub[k].length - 1] += sub[k][i]; //총점에다가 점수 누적 ..
public class Score2 {//Array로 성적짜기 한사람에 대한 데이터 1차배열 public static void main(String[] args){ java.util.Scanner input=new java.util.Scanner(System.in); String[] subname = {"국어","영어","수학"}; //0국어 1영어 2수학 3총합 int[] sub = new int[subname.length + 1]; float avg = 0.0f; //데이터 입력 부분 for (int i= 0; i < sub.length - 1; i++){ do{ System.out.print(subname[i] + " = "); sub[i] = input.nextInt(); } while (sub[..
public class Score {//2차원 배열로 성적 출력 public static void main(String[] args){ int[][] score = { {100,100,100}, {20,20,20}, {30,30,30}, {40,40,40}, {50,50,50} }; System.out.println("번호 국어 영어 수학 총점 평균"); System.out.println("=================="); for(int i=0; i
public class ArrayTest3 {//2차원 배열생성초기화 public static void main(String[] args){ //2차원 배열 선언, 생성, 초기화(명시적 배열생성) int[][] test = new int[][]{{100,200,300},{400,500,600}}; //{}안에 {},{} 가 두개 들어감 2차원 배열이기 때문에 //2차원 배열선언, 생성, 초기화(암시적 배열생성) int[][] test2 ={{100,200,300},{400,500,600}}; } } 출력이 없음
public class ArrayTest2 {//2차원배열 array public static void main(String[] args){ int test[][]; //2차원 배열 선언 test = new int[2][3]; //2차원 배열생성 //행 열 (개념) //2차원 배열 초기화 test[0][0] = 100; test[0][1] = 200; test[0][2] = 300; test[1][0] = 400; test[1][1] = 500; test[1][2] = 600; //2차원 배열 내용 사용 for(int i=0; i
public class ArrayTest1 {//배열 public static void main(String[] args){ char[] ch; //배열의 선언 ch = new char[4]; //배열 생성 //배열 초기화 ch[0] = 'J'; ch[1] = 'a'; ch[2] = 'v'; ch[3] = 'a'; //배열 내용 출력 for(int i=0;i
public class F02 {//보조 제어문 continue public static void main(String[] args){ int n; for(n=1; n 1 2 4 5 7 8 10
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=>대문자 아님