/** 로 시작하는 주석은 JavaDoc 주석이라고 해서 자바의 문서를 만들 때 사용한다. 아래 예제는 다음 URL의 문서를 생성한다.
PrintStream (Java Platform SE 7 )
Appends a subsequence of the specified character sequence to this output stream. An invocation of this method of the form out.append(csq, start, end) when csq is not null, behaves in exactly the same way as the invocation out.print(csq.subSequence(start, e
docs.oracle.com
/**
* Prints an integer and then terminate the line. This method behaves as
* though it invokes <code>{@link #print(int)}</code> and then
* <code>{@link #println()}</code>.
*
* @param x The <code>int</code> to be printed.
*/
public void println(int x) {
synchronized (this) {
print(x);
newLine();
}
}
💡 TIP ? Eclipse 주석 단축키
Ctrl + /= 한줄 주석(//)
블럭 지정 후 Ctrl + Shift + /= 여러줄 주석(/**(
Ctrl + Shift + \= 여러줄 주석 해제
8 bit (비트) | 1 byte |
1024 byte (바이트) | 1 Kilobyte |
1024 Kilobyte (킬로바이트) | 1 megabyte |
1024 megabyte (메가바이트) | 1 gigabyte |
1024 gigabyte (기가바이트) | 1 terabyte |
1024 terabyte (테라바이트) | 1 petabyte |
1024 petabyte (페타바이트) | 1 exabyte |
1024 exabyte (엑사바이트) | 1 zettabyte |
데이터 타입 | 메모리의 크기 | 표현 가능 범위 |
byte | 1 byte | -128 ~ 127 |
short | 2 byte | -32,768 ~ 32,767 |
int | 4 byte | -2,147,483,648 ~ 2,147,483,647 |
long | 8 byte | -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 |
float | 4 byte | ±(1.40129846432481707e-45 ~ 3.40282346638528860e+38) |
double | 8 byte | ±(4.95065645841246544e-324d ~ 1.79769313486231570e+308d |
char | 2 byte | 모든 유니코드 문자 |
JAVA 에서 정수의 기본 타입은 int 이고, 실수의 기본 타입은 double 이다.
flot 과 long 을 사용하기 위해서는 아래와 같이 F, L 키워드를 사용하여 형변환하여 사용한다.
package test;
public class Helloworld {
public static void main(String[] args)
{
float a = 2.2f;
long b = 2147483648l;
}
}
JAVA 에서 자동(암시적) 형 변환(implicit Conversion) 이 일어나는 규칙을 보여준다.
우선순위 | 연산자 | 결합방향 |
1 | [ ] | → |
( ) | ||
. | ||
2 | ++ | ← |
-- | ||
+(양수) -(음수) | ||
~ | ||
! | ||
(type) | ||
new | ||
3 | * / % | → |
4 | + (더하기) - (빼기) | → |
+ (문자 결합 연산자) | ||
5 | << | → |
>> | ||
>>> | ||
6 | < <= | → |
> >= | ||
instanceof | ||
7 | == | → |
!= | ||
8 | & | → |
& | ||
9 | ^ | → |
^ | ||
10 | | | → |
| | ||
11 | && | → |
12 | || | → |
13 | ? : | ← |
14 | = | |
*= /= += -= %= <<= >>= >>>= &= ^= |= |
← |
String str.equals(String); 함수를 사용하여 문자열이 같은지 비교할 수 있다.
package test;
public class Helloworld {
public static void main(String[] args)
{
String a = "Hello world";
String b = new String("Hello world");
System.out.println(a == b);
System.out.println(a.equals(b));
}
}
실행 결과
fasle
true
[JAVA] 접근제어자 (0) | 2018.06.12 |
---|---|
[JAVA] 초기화 및 생성자 (0) | 2018.06.11 |
[JAVA] 기본 문법 (0) | 2018.05.31 |
[JAVA] 설치 및 실행 (0) | 2018.05.28 |