Skip to content

Instantly share code, notes, and snippets.

@ron623
Created February 2, 2015 07:00
Show Gist options
  • Save ron623/601d2e02c691c95dd33d to your computer and use it in GitHub Desktop.
Save ron623/601d2e02c691c95dd33d to your computer and use it in GitHub Desktop.
package stringTest;
/*
* 数値の連結
*/
public class NumberCalc {
public NumberCalc() {
// TODO 自動生成されたコンストラクター・スタブ
}
public void numberToString(){
int i = 100;
int j = 200;
String s = "test";
// ①数値の計算がなされる
System.out.println(i + j);
// ②数値+文字列
System.out.println(i + s);
// ③文字列+数値
System.out.println(s + i);
// ④全て文字列として連結される
System.out.println(s + i + j);
// ⑤i+jの計算結果とsが連結される
System.out.println(i + j + s);
// ⑥sとi+jの計算結果が連結される(②と同じ結果)
System.out.println(s + (i + j));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment