public class Operator {

	  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);

	  }
	}




'Java > Operators(연산자)' 카테고리의 다른 글

대입연산자  (0) 2012.04.09
논리연산자  (0) 2012.04.09
조건 연산자  (0) 2012.04.09
증감연산자, 비교연산자, 논리연산자  (0) 2012.04.09
대소 관계를 비교하는 관계 연산자  (0) 2012.04.09
public class Operator {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		int a = 3, b = 5, c = 3;  // 변수 선언 및 초기화
		boolean istrue; 		   //변수 선언
		
		istrue = a >= b; 			   //변수 초기화 
		
		System.out.println("a > b 는 " + istrue);
		
		istrue = a * b <= b + c;    //변수 초기화 
		System.out.println("a*b < b + c는 " + istrue);
		
		
		istrue = ( a*b != b*c );      //변수 초기화 
		System.out.println("a*b == b*c는 "+ istrue);
		
		//boolean istrue; 위에서 선언했다.
		
		// &&비교는 boolean 끼리만 비교 가능 
		istrue= true && true ; // 둘다 참이면 true
		System.out.println("true && true = " + istrue);
		
		istrue = true && false; //and
		System.out.println("true && false = " + istrue);
		
		istrue = true || false; //or
		System.out.println("true || false = " + istrue);
		
		istrue = false || true; //or
		System.out.println("false || true = " + istrue);
		
		istrue = !true; 
		System.out.println("!true = " + istrue);
		
		a=1;
		System.out.println(a);
		a=++a;   // 
		System.out.println(a);
		a=++a ;
		System.out.println(a);
		a=++a ;
		System.out.println(a);
		a=--a ;
		System.out.println(a);
		a=--a ;
		System.out.println(a);
		a=--a ;
		System.out.println(a);
		a=-a ;
		System.out.println(a);
		a=-a ;
		System.out.println(a);
		
		//p 78
		a=5;
		a++; //다음번에 a를 사용할때 +1을 해라 
		
		++a; //지금 즉시 a+1를 해라 
		System.out.println("a="+a);
		
		int x=a;
		System.out.println("x="+x);
		
		a=100; // a가 변수이므로 값을 새로 바꿀 수 있음
		
		a= a+100;
		System.out.println("a="+a);
		a += 100;  // a = a+100;   //90프로 활용
		a -= 50;   // a = a - 50;
		a *= 2;    //  a = a * 2;
		a /= 2;    //  a = a / 2 ;
		
		System.out.println("a="+a);
	}

}







public class IfStudy {
	public static void main(String[] Args){
		//if 만약 () 안이 true이면 {}실행해라 
		if(false){
			System.out.println("if문 실행안합니다");
		}
		
		if(true){
			System.out.println("if문 실행합니다");
		}
		
		// 범위 주석 : 드래그 후 ctrl + shift + /
		/*if   (  10  >  1   )
			{System.out.println("ok 크다 ");
		    }*/
		
		if   (  10  <  1   ) {
			System.out.println("ok 작다 ");
			System.out.println("ok 작다 ");
		}
		 // 바로 위의 if문의 조건이 false일때 실행됩니다.
		else 
			System.out.println("no 작지 않았습니다");
		
		
		System.out.print("-----------------------\n");
		
		int number=5;
		if( number  == 5) 
		{ //2줄 이상의 소스를 실행할 때 
			System.out.println("\t nuber는 5였습니다");
		    System.out.println("\t ok");
		}
		else{  
			System.out.println("\t nuber는 5가 아니었다");
			System.out.println("\t *** \n");
		}
		
		//p 95
		int x = 5;
		
		if( x % 2 == 1)
			System.out.println(x + "는 홀수");
		else
			System.out.println(x + "는 짝수");
		
		// p 96
		int score=75;
		
		if( score>= 90){       System.out.println("A학점");}
		else if(score>= 80) { System.out.println("B학점"); }
		else if(score>= 60) System.out.println("D학점");
		else if(score>= 70) System.out.println("C학점");
		else 				     System.out.println("F학점");
		
		
		number=8; // 1 ~ 9 사이의 수를 고른다. 
		
		if(number>5){ // 5보다 크구나.  6~9
			if(number>7){ //7 보다 크구나 8~9
				if(number%2==0) System.out.println("8입니다");
				else System.out.println("9입니다");
			}
			else{ //6 ~ 7
				if(number%2==0) System.out.println("6입니다");
				else System.out.println("7입니다");
			}
			
		}
		else{  //5보다 작구나. 1~4
			if(number>3){//4~5
				if(number%2 == 1){
					System.out.println("5입니다.");
				}else{
					System.out.println("4입니다.");
				}
			}else{//1~2,3
				if(number%2==0){
					System.out.println("2입니다.");
				}
				else if(number<2){
					System.out.println("1입니다.");
				}else{
					System.out.println("3입니다.");
				}
			}
		}
	}
}



'Java > 2012.04 강좌' 카테고리의 다른 글

4일차  (0) 2012.04.06
4일차  (0) 2012.04.06
2일차 변수  (0) 2012.04.05
2일차 자료형 ,변수형  (0) 2012.04.04
2일차 eclipse 실행해보기  (0) 2012.04.04
public class IntStudy {
	public static void main(String[] args) {
		//78954+12345 =?
		//78954+55444 =?
		//78954+11345 =? //100번 물어본다면?
		System.out.println("1+2=3");
		System.out.println(78954+12345);
		
		int a=78954; //메모리에 78954 값을 저장
		//int a 변수의 선언, a=78954 변수의 초기화
		//변수 선언 초기화 하세요~
		
		int b; //b라는 변수 선언
		b=12345; //b변수 초기화
		
		int c=99955;
		
		System.out.println(a+b);
		//인간적인
		System.out.println(a+" 더하기 "+b+" 는 "+(a+b));
		
		//덜인간적인 언어 C처럼
		System.out.printf("%d 더하기 %d 는 %d \n",a,b,a+b);
		
		System.out.println(a+" 더하기 "+c+" 는 "+(a+c));
		
		// \n 한줄 띄기 "나 \n 너 \n"
		
		int d=5,e=6,f=7,g=8,h=9;//변수 선언 및 초기화
		int i,j,k,l,m,n; //변수 선언
		i=10;j=11; //변수값에 값을 초기화(initialize)
		
		/*int z=100;
		
		//int z=50; error
		
		z=2147483647;*/
		
	
		//실수 타입 float,double
		
		double pi=3.141592;
		
		float zi=3.141592f;
		
		int r=5;//반지름
		double area;//면적, 변수 선언
		
		area = r*r*pi;
		
		System.out.print("반지름이" +r+"인 원의 면적은 " +area+"이다");				
	}
}





public class Test {
	public static void main(String[] args){
		/*float a=33.33f;
		float b=55.2f;
		float c=a*b;
		
		float d=33.33f;
		float e=8.8f;
		float f=d*e;
		
		System.out.println("가로 "+a+"*"+"세로"+b+"의 직사각형의 넓이는 "+c+"입니다.");
		System.out.println("가로 "+d+"*"+"세로"+e+"의 직사각형의 넓이는 "+f+"입니다.");
		*/
		
		float aa=33.33f;
		float bb=55.2f;
		float cc=8.8f;
		String exp="의 직사각형의 넓이는";
		
		System.out.print("가로"+aa+" * " +"세로"+bb+exp+aa*bb+"입니다.\n");
		System.out.print("가로"+aa+" * " +"세로"+cc+exp+aa*cc+"입니다.\n");
	
		String hi = "안녕하세요";
		char hello='하';
		
		boolean IamGirl=false;
		boolean IamMan=true;
	}

}




'Java > 2012.04 강좌' 카테고리의 다른 글

4일차  (0) 2012.04.06
3일차  (0) 2012.04.05
2일차 자료형 ,변수형  (0) 2012.04.04
2일차 eclipse 실행해보기  (0) 2012.04.04
2일차 path 설정  (0) 2012.04.04

+ Recent posts