開発環境にJDKをインストールします。javaは.classにコンパイルすれば、Linux以外のOS(mac, windows等)のJRE(Java Runtime Environment)/JVM(Java Virtual Machine)で実行することが可能です。Run anywhereの思想です。
http://openjdk.java.net/install/
[vagrant@localhost java]$ sudo yum -y install java-1.8.0-openjdk-devel
ターミナルからのコンパイル方法です。
public class MyApp{
public static void main(String[] args){
String msg;
msg = "Hello Wrold again";
System.out.println(msg);
}
}
[vagrant@localhost java]$ javac MyApp.java [vagrant@localhost java]$ java MyApp Hello Wrold again
データ型
char a = 'a';
int x = 10;
long y = 5555555555L;
double d = 23423.344;
float f = 32.33F;
boolean flag = true; // false
// \n \t
演算
// 演算
int i;
i = 10 / 3;
i = 10 % 3;
int x = 5;
x++;
x--;
int x = 5;
x = x + 12;
x += 12;
String s;
s = "hello " + "world";
型変換(cast)
double d = 452323.231;
int i = (int)d;
int i = 10;
double d = i / 4