package org.joonzis.ex;
public class Ex01_Variable {
int b = 10;
public static void main(String[] args) {
//주석 : 실행과 상관없이 코드에 설명을 붙인 것.
// 1. // ://이후에 라인 끝까지 주석으로 인지
// 2./* */ :사이에 있는 모든 범위를 주석으로 인지
// 1.변수 선언 ( 선언과 초기화 동시 진행)
int num = 0;
float num2 = 0f;
double num3 = 0;
char ch = 0;
char ch2 = 'a';
int ch3 = 'a';
System.out.println(ch3);
String str2 = null; //null : 0번지 (주소의 초기화를 0으로 하겠다)
String str1 = ""; // "" :빈 문자열
// 2.다른 값 대입
num = 100;
num2= 1.5f;
num3 = 1.5;
ch = '한';
str1 = "Holle";
str2 = "java";
System.out.println(num);
System.out.println(num2);
System.out.println(num3);
System.out.println(ch);
System.out.println(str1);
System.out.println(str2);
// 3. 스코프 (범위)
// 1)지역 변수 : 코드블록{} 내에서만 접근 가능 , 벗어나면 소멸
// 2)전역 변수 : 모든 지역에서 사용 가능
{
int a = 10;
System.out.println ("코드 블록 내의 a =" + a);
System.out.println ("코드 블록 내의 a =" + a);
}
// 이미 블록 범위 안에 있는 변수가 소멸 되었기 때문에 접근 불가
//System.out.printle("코드 블록 밖의 a=
/*
* 1.
변수 num2에 데이터 1.5 저장
변수 num3에 데이터 1.5 저장
변수 ch에 데이터 한 저장
변수 str1에 데이터 Hello 저장
변수 str2에 데이터 Java 저장
2.
1에서 저장된 변수들 출력
**/
}
}