Skip to content

Instantly share code, notes, and snippets.

@ron623
Created February 2, 2015 06:56
Show Gist options
  • Save ron623/178276f993fa7864edb7 to your computer and use it in GitHub Desktop.
Save ron623/178276f993fa7864edb7 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(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