<h3>When Will The Progress Stop</h3>  [Image not Java but courtesy of pexels.com](pexels.com) I know I’m not going to be able to keep this up forever. Sooner or later my progress is going to stop. For now I hope I’m still making sense with what I’m posting. So let’s not delay and get my day 4 update out. <h2>What Did I Learn Today</h2> - Java Variables: Variable is a name associated with a value that can be changed. Specifically, we name the address of where the value is stored in memory, instead of having to remember the complex memory address. When you declare a variable in java you need to specify the data type as well as the variable name, eg: int i = 10; So declaring a variable ```data_type variable_name = value;``` You can also declare the variable and then assign a value ```int i;``` ```i = 100;``` - Variable Naming Conventions: Variables names need to adhere to a set of standards during your code and these include. 1. Variables cannot start with white space 2. Variables can begin with a special character 3. Variable names should start with a lowercase and second words should start with a capital letter 4. Variable names are case sensitive - There are 3 types of Variables in Java: 1. Static or class variables: they are associated with the class and common for all instances of class. If you create an object from a class, the variable would be the same for each object. A static variable remains constant and cannot be changed. When declaring the variable you use the word static before declaring the variable, eg: public static String variableName="Variable"; 2. Instance Variable: Instance variables are declared inside a class but outside and member, constructor of class. Each object has their own copy of the variable. 3. Local Variable: Variable declared inside the method of the class and their scope is limited to the method which means you can't change the variable or access them outside the method. <h2>Code For The Day</h2> Below is a sample program illustrating the use of Static, Instance and Local variables: ``` public class VariableExample { // instance variable public String myVar="instance variable"; public void myMethod(){ // local variable String myVar = "Inside Method"; System.out.println(myVar); } public static void main(String args[]){ VariableExample obj = new VariableExample(); System.out.println("Calling Method"); obj.myMethod(); System.out.println(obj.myVar); } } ``` Output ``` $ java VariableExample Calling Method Inside Method instance variable ``` <h3>I'll be posting daily, sharing my experiences on my “1 Month of Java Code” experiences”, my previous post on day 3 can be found below, so feel free to have a look: https://steemit.com/java/@run.vince.run/day-3-of-javatober-and-learning-what-the-jvm-is</h3> <h3>If you have found this post useful or interesting, please consider Commenting, Upvoting, Following and/or Resteeming</h3>
author | run.vince.run |
---|---|
permlink | java-variables-for-day-4-of-30-days-of-java |
category | java |
json_metadata | {"tags":["java","coding","steemit","teamaustralia","programming"],"image":["https://cdn.steemitimages.com/DQmVyzdbBUgcdw5mozSkQg7wpLNHpZDEEeBoaxDtxkh2U3R/codes-coding-computer-270623.jpg"],"links":["pexels.com","https://steemit.com/java/@run.vince.run/day-3-of-javatober-and-learning-what-the-jvm-is"],"app":"steemit/0.1","format":"markdown"} |
created | 2018-10-03 19:57:36 |
last_update | 2018-10-03 19:57:36 |
depth | 0 |
children | 256 |
last_payout | 2018-10-10 19:57:36 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 1.402 HBD |
curator_payout_value | 0.384 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 3,226 |
author_reputation | 202,014,829,756,154 |
root_title | "Java Variables For Day 4 Of 30 Days Of Java" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 72,567,563 |
net_rshares | 1,036,517,304,869 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
ausbitbank | 0 | 374,913,972,760 | 5% | ||
choogirl | 0 | 7,763,350,590 | 5% | ||
gamersclassified | 0 | 771,551,935 | 2.25% | ||
mikepedro | 0 | 486,239,388 | 7.5% | ||
gohba.handcrafts | 0 | 1,302,389,311 | 5% | ||
teamaustralia | 0 | 7,089,855,256 | 10% | ||
centerlink | 0 | 103,350,004,384 | 15% | ||
toofasteddie | 0 | 25,503,777,127 | 25% | ||
onethousandwords | 0 | 196,821,350 | 7.5% | ||
chrisdavidphoto | 0 | 418,088,397 | 1.12% | ||
revo | 0 | 13,140,063,878 | 15% | ||
webcoop | 0 | 285,638,220 | 7.5% | ||
masterwu | 0 | 125,943,356 | 4.5% | ||
plantstoplanks | 0 | 2,360,847,547 | 7% | ||
bobdos | 0 | 544,946,372 | 1.5% | ||
cryptwo | 0 | 1,576,537,428 | 13.5% | ||
freemon | 0 | 0 | 8% | ||
aussieninja | 0 | 24,171,287,622 | 80% | ||
bec-on-the-block | 0 | 393,061,396 | 7.5% | ||
terrylovejoy | 0 | 2,318,378,037 | 7.5% | ||
benleemusic | 0 | 10,888,131,207 | 5% | ||
runningproject | 0 | 4,818,494,407 | 35% | ||
sapphic | 0 | 1,546,417,327 | 7.5% | ||
run.vince.run | 0 | 9,890,138,075 | 100% | ||
melbourneswest | 0 | 617,318,007 | 7.5% | ||
philippekiene | 0 | 191,779,033 | 4.5% | ||
cryptoslicex | 0 | 141,947,148 | 7.5% | ||
maujmasti | 0 | 607,230,510 | 100% | ||
primersion | 0 | 365,829,211 | 26.25% | ||
msp-active | 0 | 409,507,296,116 | 75% | ||
sue-stevenson | 0 | 472,707,797 | 7% | ||
niouton | 0 | 1,493,735,761 | 6% | ||
lifeobserver | 0 | 160,098,748 | 13% | ||
anzub | 0 | 17,993,929,161 | 75% | ||
byebyehamburgers | 0 | 2,395,507,575 | 80% | ||
apshamilton | 0 | 1,488,419,451 | 7% | ||
runburgundy | 0 | 1,032,179,333 | 80% | ||
deividluchi | 0 | 303,369,968 | 7.5% | ||
jk6276 | 0 | 153,415,381 | 3% | ||
metametheus | 0 | 614,648,758 | 4.95% | ||
bernardwest | 0 | 2,012,627,830 | 7.5% | ||
ilovecoding | 0 | 801,782,284 | 10% | ||
positiveninja2 | 0 | 87,735,154 | 3.75% | ||
newtechblog | 0 | 2,219,812,273 | 100% |
Congratulations @run.vince.run! Your post was mentioned in the [Steemit Hit Parade](https://steemit.com/hit-parade/@arcange/daily-hit-parade-20181003) in the following category: * Comments - Ranked 1 with 255 comments
author | arcange |
---|---|
permlink | re-java-variables-for-day-4-of-30-days-of-java-20181003t184654000z |
category | java |
json_metadata | "" |
created | 2018-10-04 16:53:57 |
last_update | 2018-10-04 16:53:57 |
depth | 1 |
children | 0 |
last_payout | 2018-10-11 16:53:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 219 |
author_reputation | 1,148,200,457,989,592 |
root_title | "Java Variables For Day 4 Of 30 Days Of Java" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 72,626,230 |
net_rshares | 10,558,686,803 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
run.vince.run | 0 | 10,558,686,803 | 100% |
Hello! Your post has been resteemed and upvoted by @ilovecoding because **we love coding**! Keep up good work! Consider upvoting this comment to support the @ilovecoding and increase your future rewards! ^_^ Steem On!  *Reply !stop to disable the comment. Thanks!*
author | ilovecoding |
---|---|
permlink | 20181003t195750846z |
category | java |
json_metadata | {"tags":["ilovecoding"],"app":"ilovecoding"} |
created | 2018-10-03 19:57:51 |
last_update | 2018-10-03 19:57:51 |
depth | 1 |
children | 254 |
last_payout | 2018-10-10 19:57:51 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 323 |
author_reputation | 40,845,997,808 |
root_title | "Java Variables For Day 4 Of 30 Days Of Java" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 72,567,574 |
net_rshares | 10,612,569,512 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
run.vince.run | 0 | 10,237,521,611 | 100% | ||
ilovecoding | 0 | 375,047,901 | 5% |
Hello! Your post has been resteemed and upvoted by @ilovecoding because **we love coding**! Keep up good work! Consider upvoting this comment to support the @ilovecoding and increase your future rewards! ^_^ Steem On!  *Reply !stop to disable the comment. Thanks!*
author | ilovecoding |
---|---|
permlink | 20181003t195756946z |
category | java |
json_metadata | {"tags":["ilovecoding"],"app":"ilovecoding"} |
created | 2018-10-03 19:57:57 |
last_update | 2018-10-03 19:57:57 |
depth | 2 |
children | 253 |
last_payout | 2018-10-10 19:57:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 323 |
author_reputation | 40,845,997,808 |
root_title | "Java Variables For Day 4 Of 30 Days Of Java" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 72,567,578 |
net_rshares | 374,631,394 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
ilovecoding | 0 | 374,631,394 | 5% |
Hello! Your post has been resteemed and upvoted by @ilovecoding because **we love coding**! Keep up good work! Consider upvoting this comment to support the @ilovecoding and increase your future rewards! ^_^ Steem On!  *Reply !stop to disable the comment. Thanks!*
author | ilovecoding |
---|---|
permlink | 20181003t195802978z |
category | java |
json_metadata | {"tags":["ilovecoding"],"app":"ilovecoding"} |
created | 2018-10-03 19:58:03 |
last_update | 2018-10-03 19:58:03 |
depth | 3 |
children | 252 |
last_payout | 2018-10-10 19:58:03 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 323 |
author_reputation | 40,845,997,808 |
root_title | "Java Variables For Day 4 Of 30 Days Of Java" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 72,567,580 |
net_rshares | 374,215,304 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
ilovecoding | 0 | 374,215,304 | 5% |