public static void main(String[] args) {
// 두 개의 변수가 같은 데이터 타입일 때 아래와 같이 코드를 작성한다.
String a, b;
}
여러줄 주석
public static void main(String[] args) {
String a, b;
/*
a = "coding";
b = "everybody";
System.out.println(a+b);
*/
}
JavaDoc 주석
/**
* 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();
}
}
package org.opentutorials.javatutorials.variables;
public class IntergerDemo {
public static void main(String[] args) {
int a;
a = 1;
System.out.println(a+1); //result:2
a = 2;
System.out.println(a+1); //result:3
}
}
실수
package org.opentutorials.javatutorials.variables;
public class DoubleDemo {
public static void main(String[] args) {
double a = 1.1;
System.out.println(a+1.1); // result: 2.2
a = 2.1;
System.out.println(a+1.1); // result: 3.2
}
}
문자열
package org.opentutorials.javatutorials.variables;
public class StringDemo {
public static void main(String[] args) {
// String first;
// first = "coding";
// String first = "coding";
String a, b;
a = "coding";
b = "everybody";
System.out.println(a+ " " +b); //result: coding everybody
}
}