0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

\tの使い方 macとWindowsで異なるエスケープシーケンス-java

Last updated at Posted at 2019-10-09

文字列内で使う時

sample
		System.out.println("美味しい\tみかん");

コンソール: 美味しい みかん

変数を使う時

sample
		String sample1 = "ふつうの";
		String sample2 = "いちご";
		System.out.println(sample1 + "\t" + sample2);

コンソール: ふつうの いちご

Windows

sample
		System.out.println(sample1 + "\t" + sample2);
		System.out.println(sample1 + "¥t" + sample2);

\と¥両方が使える

mac

sample
		System.out.println(sample1 + "\t" + sample2);
		System.out.println(sample1 + "¥t" + sample2); //macではバックスラッシュと円記号が区別される

コンソール:
ふつうの いちご
ふつうの¥tいちご

エスケープシーケンス(一部)

エスケープシーケンス 記号の意味 Center align
¥" ダブルクォーテーション
¥' シングルクォーテーション
column 改行
will ¥(円)マーク will
be be be
left right center
aligned aligned aligned
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?