Can anyone help me get started on this instruction for a for loop:
Ask the user for 2 integers. Print all the numbers BETWEEN them

and also this one

When everything else works, implement a for loop that is an infinite loop

I have no idea where to start with these two?

Okay I will help you out with the basic structure of your program.

Firstly get the inputs. (and a if statement that figures out which number is larger.

Secondly the loop.
IE for(int i=smallerNumber; i<biggerNumber; i++) good luck!!

IE for(int i=smallerNumber; i<biggerNumber; i++)

he's asking for an infinite loop. little does he know, he already wrote one in his previous post:

for( int i = 3; i < 41; i)

{
System.out.println(" Numbers are " + i);
}

this is an infinite loop, since you never raise or change the value of i. i will always have the value 3, thus will always be smaller then 41, hence this loop will run, infinitely

@nandomendonza : I would like to ask one question of you first. Have you been taught the for loop in the class (I assume you are in a class since you mention the word instruction) where you got this instruction.
If yes, do you think it is so tough, after knowing how a for loop functions, to implement both the instructions, that you post it in a forum ? Both the for loop constructs could have been built before you completed writing your post.
If no, then I suggest you ask your instructor for the same. Then try it on your own. In no programming language a for loop construct is such an uphill task that you won't be abe to do it, if you really make up your mind. Not to mention that even an uphill task would not remain that impossible if you make up your mind on it.
It's my appeal to all the beginners here, through this post that you are supposed to try such things on your own. If you are struggling to get it correct, even after a week's time - and a week it should be - then you could may be make up your mind whether to post the problem on a forum or give up programming altogether, and believe me if you are struggling to write a for loop construct for a week the latter isn't a bad option at all.

Edit : I mention a week's time here since I religiously believe that no amount of effort put in while learning something new would go to waste.

Comments
You can say things very well

Yes, I am taking a class and I have this assignment to do and I was just posting on this forum to get some help. I am having a hard time understanding and that is why I explained if somebody could help me understand or help me get started on the code. I do find it tough, I find it tough to understand what it is that my code means when I write it.

> Yes, I am taking a class

You should convey to your professor the problems you are facing and ask him to help you out even if it means spending some extra time for it. One-to-one help is far better than trying to understand the same by asking on message boards.

@nandomendonza : I would like to ask one question of you first. Have you been taught the for loop in the class (I assume you are in a class since you mention the word instruction) where you got this instruction.
If yes, do you think it is so tough, after knowing how a for loop functions, to implement both the instructions, that you post it in a forum ? Both the for loop constructs could have been built before you completed writing your post.
If no, then I suggest you ask your instructor for the same. Then try it on your own. In no programming language a for loop construct is such an uphill task that you won't be abe to do it, if you really make up your mind. Not to mention that even an uphill task would not remain that impossible if you make up your mind on it.
It's my appeal to all the beginners here, through this post that you are supposed to try such things on your own. If you are struggling to get it correct, even after a week's time - and a week it should be - then you could may be make up your mind whether to post the problem on a forum or give up programming altogether, and believe me if you are struggling to write a for loop construct for a week the latter isn't a bad option at all.

Edit : I mention a week's time here since I religiously believe that no amount of effort put in while learning something new would go to waste.

Sei nicht so hart man, jeder fängt mit dem gleichen Scheiss an...

Dont be so harsch on the poor guy. We all started with such trivialities...

nandomendoza

start with writing pseudocode of what you want your program to do. It's just plain english

start program
--program does this
--if program input is this then do this

etc

after you get that done then go to the smallest thing you know how to do. Maybe it's declare a variable, whatever that is do the smallest chunk first. At this point you're putting some thought into your work that is constructive. When you get to a point where you can't do something post again

Dont be so harsch on the poor guy. We all started with such trivialities...

Yes NightStrider, we do all start with such trivialities but the fact that makes us what we are is "What we do about them".

Putting myself in his shoes, I wouldn't have been on a public forum asking for the magic pill which would hardwire all the concepts of Java "for" loop inside my brain, rather I (and most of the others who excel at programming) would spend that extra time reading that Java Reference Book (again and again) or just making up some trivial code snippets and experimenting with them trying out what happens if when you add "X" to your code, remove "Y" from somewhere else and observe what happens and so on, even others(who do not have this appetite) would opt to ask their instructor what to do just as Verruckt suggested.

@nandomendoza

Thank you, I just started learning this stuff.

Just because you are new to Java doesn't give you a license to be unaware of basics like these and not experiment and find out the behaviour of Java on your own. Also the sticky "Starting Java" has numerous resources that are supposed to help beginners like yourself, How many of those did you read before posting this thread ?
When beginners show the effort by writing their code or by showing some effort on research on their own from the web or by citing from their text books or by coding some work, you will find numerous examples where we do not mind going the extra mile to help them.
However you have done neither of them (not even tried) and just posted what your instructor has asked you to do.
And for every question you cite "I am a beginner, I find it difficult that is why I cannot do it".
Just Let me know who's stopping you from writing a small Java code snipppet with a "for" loop and compiling it, Yes you may get compile errors, may be even runtime exceptions, but thats when what you are learning will stick, when you are doing it on your own. Not only that, by reading those errors trying to interpret them and correct them you will learn ten fold more about debugging, a skill you will need (and people will envy) if you are going to stick to this field of Software development.

Sei nicht so hart man, jeder fängt mit dem gleichen Scheiss an...

Dont be so harsch on the poor guy. We all started with such trivialities...

I don't know about you, but atleast I did not post on a forum for a for loop construct for any of the four programming languages I have learnt and also I assume none of the others who have posted here, did that. And if you think I was being harsh on him for asking help for such a trivial thing, then harsh I am, because I believe that if you are screwing up on something and nobody even bothers to tell you that, then it means that they have given up on you. Sometimes you need to take up the initiative and show a practical mirror to someone who badly needs it.

This question has already been answered. Start a new discussion instead.