What is meant by the assignment here and why is this not an initialization?

I have this example here:

 int methode() { int h = 47; // Hilfsvariable for (int i = 1; i <= 10; i++) { ...... h = h + c; || Zuweisung, aber keine Initialisierung } return h ]

I got this example from my class. Initialization means the first value assignment. But it is not used in the

 int h = 47

already initialized, ie the variable h is assigned the value 47?

I think I misunderstood something. Please enlighten me, I need an answer.

Thanks everyone for help in advance.

PS: I am a beginner in Java.

1 vote, average: 1.00 out of 1 (1 rating, 1 votes, rated)
You need to be a registered member to rate this.
Loading...
Subscribe
Notify of
4 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
jo135
1 year ago

But is not initialized at the int h=47, ie the variable h is assigned the value 47?

Yeah, that's right. And later a new value will be assigned.

regex9
1 year ago
Reply to  jo135

By the way, the variable alone would be initialized by declaration (…)

No, local variables are not implicitly initialized.

Gehilfling
1 year ago

Right. With the line "int h = 47", the variable is defined and simultaneously initialized. Later, an assignment to another value only takes place, but no renewed initialization.

Kalkablagerung
1 year ago

Yes, initialization means that the memory is reserved; that means where the memory is reserved in the program (if you do "int h" eg).

This means "int h=47;" is an initialization, since here the first time hears from the variable h in the program. Only new assignments follow in the loop.