So this is java huh?

So this is java huh?
for (;;) {
}

while :; do
done

unix greybeards btfo

That's also valid C.

That's actually used by C autists. Java programmers would use while (true) since it is easier to read.

for (;;) {
if(true)
continue;
}

Just because it is technically possible doesn't mean it will be used and is standard practice.

for(;;)
if(true)
continue;

Fucking disgusting

while (true) {}
Is the only correct way.

Yes OP, this is java and it is used when you know the exact number of repetitions.

see

Retard.
He's obviously talking about infinite loops.

>it is used when you know the exact number of repetitions.
Wrong.

With assume you make an ass of u and me?

He never mentioned infinity, just asked whether it is java or not.

#define existence 1
#define pain 1

while (existence == pain);

>wrong
Well use a while to give the the sum of all even numbers up to 100 then :^)

Empty for loop is faster if you disable all optimizations.

That wasn't the point, fucktard.
For loops are perfectly suitable for some situations where the number of iterations is not known.

int sum = 0;
int i = 2;
while (i < 100)
{
sum += i;
i += 2;
}

That is bad practice though.

Make sure your code is acceptable in an office environment.

You know that meme where someone will re-word your post to point out some percieved retardation?

>Empty for loop is faster if you disable all optimizations.

>That is bad practice though.
Wrong.

>That is bad practice though.
How is this bad practice?

void foo(int n)
{
for (int i = 0; i < n; ++i) // number of iterations is not known until runtime
{
// ... do stuff
}
}

>when I predicted I had to use ":^)"

And then you call Indians pajeets...

do {
} until(op != "faggot");

>while(1 == 1)
brainlet
>while(1)
>while(true)
below average
>for(;;)
intellectuals

>when I predicted I had to use ":^)"
What did he mean by this?

Number is known this way though. Probably not to the programmer, but number is defined before the loop. Therefore it is known.

Lmao

So how do you do a foreach in this language?

>Oog boog , he's autistic if I cannot argue

_:
goto _;

true patrician

>this language
?

while(1){
int sum = 50 * (2 + 100) / 2;
break;
}

for (Object o : objects)

for (;;) is retardation. Just because it's less readable doesn't mean it's better.
while (true) is objectively superior, or even better loop {}, this is common sense and not debatable.

No one fucking cares about performance on -O0.
If you cared, you'd enable optimizations which makes them both exactly the same performance-wise.

>Number is known this way though. Probably not to the programmer, but number is defined before the loop. Therefore it is known.
Okay, how about this then:

size_t strlen(const char* s)
{
size_t n;
for (n = 0; s[n] != '\0'; ++n);
return n;
}


Here the number of iterations is not known until the condition is met.

Where again it IS known just before the iteration, I don't get how you perceive language...

You cannot compile a for loop with something that has a possibility to have no value when the loop starts.

myCollection.forEach(SomeClass::doThingMethodRef)

kek

>No one fucking cares about performance on -O0.
I started using ++i instead of i++ because Sup Forums told me it was better.

>Where again it IS known just before the iteration,
No, it isn't. Hint: memory can change, for example by another thread.

>You cannot compile a for loop with something that has a possibility to have no value when the loop starts.
That's exactly what that is..... What the hell?

Try and compile that shit then :)

a for loop cannot be compiled if the compiler sees there's a possibility it gets no value

doing something because someone on Sup Forums said it was better is a pretty stupid thing to do.

>not knowing difference between postfix and preix
Brainlet

We are talking about for loops.
Can you connect the dots and predict the context?

>Try and compile that shit then :)
???

>is this java

#include
#include
#include
#include


int main()
{
size_t its;
size_t n_its;

srand(time(NULL));
n_its = rand() % 2;

for (its = 0; its != n_its; its += 2); // will it terminate?

return 0;
}


No, it's C. But I can do the same in Java

>will it terminate?
its will never be 1.

That's the point. n_its can be either 0 or 1. Whether or not the loop terminates is indeterminable.

well if it doesn't terminate, it'll eventually overflow. I know that's unfedined behavior for a signed int, but size_t is unsigned, and I forget whether C mandates the expected overflow behavior for unsigned types, or leaves it undefined.

unsigned integer overflow is defined.

>don't be a rectangle
Is that the bait here?

Streams are fun.
Like a toy baby version of real programming language constructs.

Gay and fake

>string, not object

Meme degree

This is also valid C and C++.

draiiiinn gang

Infinite loops are an impossibility.

From kikebook. Made me chuckle

10 GOTO 10

You are a stupid brainlet, OP.

Fine
do {
} until(op != new Faggot());

What retarded compiler wouldn't optimize an unused value return out of a unaccessed postincrement?

It's "better" primarily as a style thing. Because embedded preincrement operations are generally a poor style choice. It's fine when you're just doing "id = workingId++", but deeply embedding it into the logic of a comparison operator or function call makes the code convoluted. In a preincrement, it's standard nested logic, but in a postincrement, you're creating two entirely separate branches of logic: one in which its current value is being used and one in which its internal value is being incremented and it makes it very easy to overlook or misunderstand when the value changes if you're reading someone else's "clever" code. If weird function calls don't make that 100% necessary then you really should just put the increment on another line.

That's not how you compare types in any language.

>He doesn't know about operator overloading

Why would you overload the equivalent operator to be true if they're the same type? That's like making any integer compared to any other integer return true.

op and new Faggot are both instances of the class Faggot

That's exactly what said. Why are you comparing types instead of values?

Read the Java source code.

That's fucking disgusting m8

What's the lmao for? It's a valid and correct sentence.

CET detected

Just stop trying to microoptimise, it's the job of the compiler.
You're just going to waste time and potentially make things even worse.

Pretty sure that works in c too