aspose file tools*
The moose likes Beginning Java and the fly likes Difference between Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between "Initialization" and "Assignment" ?" Watch "Difference between "Initialization" and "Assignment" ?" New topic
Author

Difference between "Initialization" and "Assignment" ?

Anupam Bhatt
Ranch Hand

Joined: Mar 12, 2004
Posts: 81
Hi,

Quick question, what is the difference between initialization of a variable and assignment of a variable. I would say "the first assignment to a variable is initialization", is that correct? views?

Oh BTW this question struck to me after reading this statement "A local variable must be explicitly given a value, by either initialization or assignment, before it is used. "
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36453
    
  15
Assignment of a variable (or its name) means giving that variable to a value as its name.

myField = ...

You can assign several variables to the same value and (if not final) you can assign the same variable to different values at different times.
Read the assignment operator as "becomes equals to" or "receives the value of".

I think most people take initialisation to mean assigning a value to a variable or field in the same statement it is declared in.

Foo myField = new Foo();
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between "Initialization" and "Assignment" ?
 
Similar Threads
complie time constants
instance/reference
Say 4A: Array initialization confusion
what is the difference between static variable and static block
What's the difference between instance variable and class variable?