// 1.대소문자를 구분한다.
int a; int A; // 다른 변수 2개를 선언한 것이다.
// 2.int double과 같은 예약어, 키워드를 사용하면 안된다.
int int=10; //안된다.
// 키워드는 자바 문법으로 사용하는 약속된 문자열을 의미한다. 예약어는 키워드로 예약되어 있는 문자열이다.
// 3.숫자로 시작해서는 안된다.
int 1a=10;//안된다.
int a1a=20; //된다.
int a1=50; //된다.
// 4.특수문자는 `_` `$` 두 가지만 허용된다.
int _a=5; //된다. 되도록 사용하지 말자.
int 3i=5;//x starting with number
int i3i=5;//o
int __hello=55;//o
int hello=5.3;//x type mismatch
int i+j=4;//특수기호는 x
int public=5;//키워드 x
int i#2=5;//x 특수문자
int MyCatAge=10;//관용적 X
int mycatage=20;//관용적 X
public class myCat(){}//관용적 X
String name = "홍길동";
int age = 29;
double height = 170.1;
System.out.println(name + "\n" + age + "\n" + height);
a
에 5
,b=10
를 넣은 다음 a
,b
의 합을 화면에 출력해 보자.
int a = 5;
int b = 10;
System.out.println(a + b);
변수:myComputerSpecifications
클래스:MyComputerSpecifications
상수:MY_COMPUTER_SPECIFICATIONS
해석: Play with the cat
변수:playWithTheCat
클래스:PlayWithTheCat
상수:PLAY_WITH_THE_CAT