0
1

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 1 year has passed since last update.

きっかけ

いつも使っているfor文の初期値などに、int以外の型も使えるということを知り
面白くなっていろいろ試してみようと思いました。

試した型

・char型
ソース

for(char c = 'A';c <= 'Z';c++) {
			
			System.out.println(c);
		}

結果:大文字のAからZまでがアルファベット順に表示される
image.png

・double(1)
ソース

for(double d = 1.125;d <= 3.363;d++) {
			
			System.out.println(d);
		}

結果
image.png

・double(2)
ソース

		for(double d = 1.5;d <= 3.5;d+=0.3) {
			
			System.out.println(d);
		}

結果
image.png
→なぜ途中から少数桁がびよよんと増えるのかが謎なので今後の課題です。

型はまだまだいろいろあるので、どんな面白い挙動になるかこれからも遊んでみたいです。

0
1
2

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?