Initialization and declaration whats the difference please? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Initialization and declaration whats the difference please?

9th Aug 2017, 6:15 AM
D_Stark
D_Stark - avatar
4 Answers
+ 3
int a; // declaration a = 5; // initialization int b = a; // declaration with initialization declaration consists of any modifier(s), type, and variable name. initialization, simply put, means that the variable has been set at least once. https://stackoverflow.com/questions/2614072/java-define-terms-initialization-declaration-and-assignment https://teamtreehouse.com/community/what-is-the-difference-between-declaring-a-variable-and-initializing-a-variable
9th Aug 2017, 6:29 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
thanks i think i get it does this look right? int x; < declaration x = 5 ; < initialization x = 10; < assignment as x is already initialized
9th Aug 2017, 9:00 AM
D_Stark
D_Stark - avatar
+ 2
thanks agin for your help 👍
9th Aug 2017, 9:06 AM
D_Stark
D_Stark - avatar
+ 1
👍
9th Aug 2017, 9:01 AM
ChaoticDawg
ChaoticDawg - avatar