If a “private static int” instance variable is not initialized, does it equal to zero? [duplicate]
up vote
-1
down vote
favorite
This question already has an answer here:
default values for primitives
3 answers
If a "private static int" instance variable is not initialized, does it equal to zero?
For example:
private static int number;
Is number equal to zero?
java
marked as duplicate by nullpointer
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 11 at 10:52
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
-1
down vote
favorite
This question already has an answer here:
default values for primitives
3 answers
If a "private static int" instance variable is not initialized, does it equal to zero?
For example:
private static int number;
Is number equal to zero?
java
marked as duplicate by nullpointer
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 11 at 10:52
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
yes - 0 is the default value.
– Eran
Nov 11 at 10:52
Why don't you try it? And YES.
– Nicholas K
Nov 11 at 10:52
@Eran this doesn't apply to non-static variables too, right?
– user10610048
Nov 11 at 10:52
5
@user10610048 it applies to both static and instance variables. It doesn't apply to local variables.
– Eran
Nov 11 at 10:54
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
This question already has an answer here:
default values for primitives
3 answers
If a "private static int" instance variable is not initialized, does it equal to zero?
For example:
private static int number;
Is number equal to zero?
java
This question already has an answer here:
default values for primitives
3 answers
If a "private static int" instance variable is not initialized, does it equal to zero?
For example:
private static int number;
Is number equal to zero?
This question already has an answer here:
default values for primitives
3 answers
java
java
asked Nov 11 at 10:51
user10610048
676
676
marked as duplicate by nullpointer
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 11 at 10:52
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by nullpointer
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 11 at 10:52
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
yes - 0 is the default value.
– Eran
Nov 11 at 10:52
Why don't you try it? And YES.
– Nicholas K
Nov 11 at 10:52
@Eran this doesn't apply to non-static variables too, right?
– user10610048
Nov 11 at 10:52
5
@user10610048 it applies to both static and instance variables. It doesn't apply to local variables.
– Eran
Nov 11 at 10:54
add a comment |
yes - 0 is the default value.
– Eran
Nov 11 at 10:52
Why don't you try it? And YES.
– Nicholas K
Nov 11 at 10:52
@Eran this doesn't apply to non-static variables too, right?
– user10610048
Nov 11 at 10:52
5
@user10610048 it applies to both static and instance variables. It doesn't apply to local variables.
– Eran
Nov 11 at 10:54
yes - 0 is the default value.
– Eran
Nov 11 at 10:52
yes - 0 is the default value.
– Eran
Nov 11 at 10:52
Why don't you try it? And YES.
– Nicholas K
Nov 11 at 10:52
Why don't you try it? And YES.
– Nicholas K
Nov 11 at 10:52
@Eran this doesn't apply to non-static variables too, right?
– user10610048
Nov 11 at 10:52
@Eran this doesn't apply to non-static variables too, right?
– user10610048
Nov 11 at 10:52
5
5
@user10610048 it applies to both static and instance variables. It doesn't apply to local variables.
– Eran
Nov 11 at 10:54
@user10610048 it applies to both static and instance variables. It doesn't apply to local variables.
– Eran
Nov 11 at 10:54
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Yes. Since the default value for int will be 0
Does this apply to non-static instance variables too?
– user10610048
Nov 11 at 10:53
It applies to instance variables as well
– Sand
Nov 11 at 10:55
1
Just to make it clear it's not"0"
but0
– Peter Lawrey
Nov 11 at 10:56
2
Yes. Didn't mean it as a String. Just wanted to highlight it. Thanks @PeterLawrey
– Sand
Nov 11 at 10:57
use ` and ` to highlight as code.
– Peter Lawrey
Nov 11 at 11:13
|
show 1 more comment
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Yes. Since the default value for int will be 0
Does this apply to non-static instance variables too?
– user10610048
Nov 11 at 10:53
It applies to instance variables as well
– Sand
Nov 11 at 10:55
1
Just to make it clear it's not"0"
but0
– Peter Lawrey
Nov 11 at 10:56
2
Yes. Didn't mean it as a String. Just wanted to highlight it. Thanks @PeterLawrey
– Sand
Nov 11 at 10:57
use ` and ` to highlight as code.
– Peter Lawrey
Nov 11 at 11:13
|
show 1 more comment
up vote
1
down vote
accepted
Yes. Since the default value for int will be 0
Does this apply to non-static instance variables too?
– user10610048
Nov 11 at 10:53
It applies to instance variables as well
– Sand
Nov 11 at 10:55
1
Just to make it clear it's not"0"
but0
– Peter Lawrey
Nov 11 at 10:56
2
Yes. Didn't mean it as a String. Just wanted to highlight it. Thanks @PeterLawrey
– Sand
Nov 11 at 10:57
use ` and ` to highlight as code.
– Peter Lawrey
Nov 11 at 11:13
|
show 1 more comment
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Yes. Since the default value for int will be 0
Yes. Since the default value for int will be 0
edited Nov 11 at 10:55
Peter Lawrey
438k55552952
438k55552952
answered Nov 11 at 10:52
Sand
7259
7259
Does this apply to non-static instance variables too?
– user10610048
Nov 11 at 10:53
It applies to instance variables as well
– Sand
Nov 11 at 10:55
1
Just to make it clear it's not"0"
but0
– Peter Lawrey
Nov 11 at 10:56
2
Yes. Didn't mean it as a String. Just wanted to highlight it. Thanks @PeterLawrey
– Sand
Nov 11 at 10:57
use ` and ` to highlight as code.
– Peter Lawrey
Nov 11 at 11:13
|
show 1 more comment
Does this apply to non-static instance variables too?
– user10610048
Nov 11 at 10:53
It applies to instance variables as well
– Sand
Nov 11 at 10:55
1
Just to make it clear it's not"0"
but0
– Peter Lawrey
Nov 11 at 10:56
2
Yes. Didn't mean it as a String. Just wanted to highlight it. Thanks @PeterLawrey
– Sand
Nov 11 at 10:57
use ` and ` to highlight as code.
– Peter Lawrey
Nov 11 at 11:13
Does this apply to non-static instance variables too?
– user10610048
Nov 11 at 10:53
Does this apply to non-static instance variables too?
– user10610048
Nov 11 at 10:53
It applies to instance variables as well
– Sand
Nov 11 at 10:55
It applies to instance variables as well
– Sand
Nov 11 at 10:55
1
1
Just to make it clear it's not
"0"
but 0
– Peter Lawrey
Nov 11 at 10:56
Just to make it clear it's not
"0"
but 0
– Peter Lawrey
Nov 11 at 10:56
2
2
Yes. Didn't mean it as a String. Just wanted to highlight it. Thanks @PeterLawrey
– Sand
Nov 11 at 10:57
Yes. Didn't mean it as a String. Just wanted to highlight it. Thanks @PeterLawrey
– Sand
Nov 11 at 10:57
use ` and ` to highlight as code.
– Peter Lawrey
Nov 11 at 11:13
use ` and ` to highlight as code.
– Peter Lawrey
Nov 11 at 11:13
|
show 1 more comment
yes - 0 is the default value.
– Eran
Nov 11 at 10:52
Why don't you try it? And YES.
– Nicholas K
Nov 11 at 10:52
@Eran this doesn't apply to non-static variables too, right?
– user10610048
Nov 11 at 10:52
5
@user10610048 it applies to both static and instance variables. It doesn't apply to local variables.
– Eran
Nov 11 at 10:54