Loop Counters in Java

preview_player
Показать описание
Writing a "for" loop using input from the user. I'll show you how to print out the numbers from 1 to n, where n is the input value. I also show how to handle "bad" input from the user, like non-numbers or invalid numbers.
Рекомендации по теме
Комментарии
Автор

Suggest you say that int is primitive
i.e. not an Object like Integer

Thanks. I picked up a couple of good ideas to improve my own code:
adding code to trigger an event for ActionPerfomed on the text input field;
and throwing the NumberFormatException

I don't remember anymore when or where I starting abbreviating the exceptions like you did in your example. "nfe". Looks like I was not the only one to do that years ago.

You are a great teacher. Your real time screen capture program is excellent. Is it an open source program?

I was taught to use i, j, k for index variables way back in the late 1960s when I first was taught Fortran. It is amazing that somehow so many of us do that still and we adopt unwritten conventions like that.

Best wishes.

You should be teaching students in college.

cbellh
Автор

What if my input on the textfield is a string?

PolarizedLiv
join shbcf.ru