SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
K. Tsang CEng MBCS PMP PMI-ACP OCMJEA OCPJP
for (num1 * num2 == result) //(have problem)
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:
for (num1 * num2 == result) //(have problem)
I'm not sure what you are trying to do here. What you have in your parens: "num1 * num2 == result" is essentially a boolean. it's either 'true' or 'false'.
A 'for' statement doesn't take a boolean - it takes three things for setting up, testing, and updating variables. Then, the code inside the curly brackets potentially runs multiple times.
So really, the question is, what are you trying to DO there? Are you trying to test something? i don't think so, because it's a repeat of what's in your if statement just above it.
I assume you are trying to loop around and print out all those products.
So, as others have said, look in a book or online tutorial for how to set up a for-loop. Then, see if you can write one that does nothing more that prints "hello" 12 times. Then get it to print something like:
1
2
3
4
5
6
7
8
9
10
11
12
etc, and add a little bit each time.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Has whoever is teaching you not taught you about the structure of a for loop?ELL TIM wrote:..also new to java programming...