Java tutorial - How to use For loops

preview_player
Показать описание
This goes into detail how to use a For statement and it's parameters.
Рекомендации по теме
Комментарии
Автор

I'm doing a number guessing game from 1 to 10. I want the program to ask 3 times. I'm having trouble with the for loop. Do I put the variable in the parameter? Or is the problem in the if statement.

walsh
Автор

In Netbeans' Graphical user interface, I have two text fields - one for the user to type a number and the other for them to type a larger number. There's also an enter button. When they click the enter button, I want to display on another label all the numbers between the smaller and larger number they entered including the two numbers they entered. 

I have used this code to achieve this: 

String Strno1 = txtno.getText(); 

String Strno2 = txtno2.getText(); 
int intno2 = Integer.parseInt (Strno2); 

for (intno1= Integer.parseInt(Strno1); intno1 <= intno2; intno1++) 

lbloutput.setText (String.valueOf(intno1)); 


But, when the user clicks enter, nothing is displayed at all. 

Can you please explain why & what code I can use to solve this problem? Thank you.

adriennedubois
Автор

I need to do something like this with * can you please help me with this or any one help me with this i need to put it in one for loop not more than one if already done one where i had to create it with 2 for loops but cant seem to get the way i have to do this with just one loop please help
*
**
***
****






wowdarkstar