GPWiki.org
GPWiki.org
It is currently Tue Jun 18, 2013 9:18 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: General Java quiestion
PostPosted: Tue Sep 06, 2011 4:32 pm 
Novice
User avatar

Joined: Thu Sep 01, 2011 3:44 pm
Posts: 6
Hey guys!

There is something I can't figure out long ago.
What is the difference (is any?) between the following two code snippets:

Code:
public class MyClass {   
   int someValue = 9;   
   public MyClass() {}   
   // ...   
}
Code:
public class MyClass {   
   int someValue;   
   public MyClass() {
      someValue = 9;
   }   
   // ...   
}
:confused

_________________
The ultimate source of FREE programming tutorials.


Top
 Profile  
 
PostPosted: Wed Sep 07, 2011 9:07 am 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3746
Location: South Africa
My previous reply got eaten by my browser randomly logging out as I clicked Preview. >:(

Basically there's no difference. For your purposes I wouldn't worry about it. The variables defined outside of the constructor get set before those inside the constructor. I think you're forced to define things outside the constructor when they're static const. eg:
Code:
static const int N = 100;

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
PostPosted: Wed Sep 07, 2011 10:26 am 
Novice
User avatar

Joined: Thu Sep 01, 2011 3:44 pm
Posts: 6
Thank you for your reply!

_________________
The ultimate source of FREE programming tutorials.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group