{"id":98,"date":"2012-11-11T19:19:46","date_gmt":"2012-11-11T19:19:46","guid":{"rendered":"http:\/\/ilias-laptop\/examples\/java-basics\/statics\/static-variables-example\/"},"modified":"2020-05-15T18:45:13","modified_gmt":"2020-05-15T15:45:13","slug":"static-variables-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/","title":{"rendered":"Static Variable Java Example"},"content":{"rendered":"<h2 class=\"wp-block-heading\">1. Introduction<\/h2>\n<p>This is a static variable Java Example. <code>Static variables<\/code> are declared with the static word before the type of variable. The main difference among regular variables is that <code>static variables<\/code> are not bounded by any object instances, and are shared among all instances.<\/p>\n<pre class=\"brush:java\">static datatype Variable\n\/\/static variable example\nstatic int count = 0; <\/pre>\n<h2 class=\"wp-block-heading\">2. Simple Static Variable Java Example<\/h2>\n<p><code>Static variables<\/code> are useful when we need to declare a specific value among all instances. We can access <code>Static variables<\/code> in 2 ways:<\/p>\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"alignright size-large\"><img decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" alt=\"static variables java\" class=\"wp-image-1204\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg 150w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo-70x70.jpg 70w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/figure>\n<\/div>\n<ol class=\"wp-block-list\">\n<li> By Class name<\/li>\n<li> By Instance name<\/li>\n<\/ol>\n<p> Create a class with name <code>Laptop<\/code> and paste the following code : <\/p>\n<p><span style=\"text-decoration: underline\"><em>Laptop.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks;\n\/**\n * @author Petros Koulianos\n *\n *\/\npublic class Laptop {\n\n\t\/\/static variable\n\tpublic static String motherboard = \"ASUS\";\n\t\n\tpublic String cpu ;\n\t\n\tpublic String monitor_dimension ;\n\t\n\tpublic String storage ;\n\t\n\t\n\n}\n<\/pre>\n<p>Create a second class with name <code>StaticVariableExample1<\/code> and paste the following code :<\/p>\n<p><span style=\"text-decoration: underline\"><em>StaticVariableExample1.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks;\n \n\/**\n * @author Petros Koulianos\n *\n *\/\npublic class StaticVariableExample1 {\n     \n \n    public static void main(String[] args) {\n           \t\n        Laptop laptop1 = new Laptop();\n         \n        laptop1.cpu = \"i5\";\n         \n        laptop1.monitor_dimension = \"15 inch\";\n         \n        laptop1.storage = \"500 gb\";\n         \n        Laptop laptop2 = new Laptop();\n         \n        laptop2.cpu = \"i3\";\n         \n        laptop2.monitor_dimension = \"17 inch\";\n         \n        laptop2.storage = \"1 tb\";\n         \n        \/\/static variables can be access with Class name or with instance name\n        \/\/preferred way is to refer with Class name\n        System.out.println(\"laptop1  motherboard:\"+Laptop.motherboard+\" cpu:\"+laptop1.cpu+\" monitor_dimension:\"+laptop1.monitor_dimension+\" storage:\"+laptop1.storage);\n         \n        System.out.println(\"laptop2  motherboard:\"+laptop2.motherboard+\" cpu:\"+laptop2.cpu+\" monitor_dimension:\"+laptop2.monitor_dimension+\" storage:\"+laptop2.storage);\n         \n        \/\/ The company has change the motherboard\n        Laptop.motherboard = \"GIGABYTE\";\n         \n         \n        System.out.println(\"laptop1  motherboard:\"+Laptop.motherboard+\" cpu:\"+laptop1.cpu+\" monitor_dimension:\"+laptop1.monitor_dimension+\" storage:\"+laptop1.storage);\n         \n        System.out.println(\"laptop2  motherboard:\"+laptop2.motherboard+\" cpu:\"+laptop2.cpu+\" monitor_dimension:\"+laptop2.monitor_dimension+\" storage:\"+laptop2.storage);\n \n    }\n     \n \n}\n<\/pre>\n<p><span style=\"text-decoration: underline\"><em>Example Output<\/em><\/span><\/p>\n<pre class=\"brush:bash\">laptop1  motherboard:ASUS cpu:i5 monitor_dimension:15 inch storage:500 gb\nlaptop2  motherboard:ASUS cpu:i3 monitor_dimension:17 inch storage:1 tb\nlaptop1  motherboard:GIGABYTE cpu:i5 monitor_dimension:15 inch storage:500 gb\nlaptop2  motherboard:GIGABYTE cpu:i3 monitor_dimension:17 inch storage:1 tb\n<\/pre>\n<p>The above example shows how to declare a <code>static variable<\/code> and how to access it.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<h2 class=\"wp-block-heading\">3. Static Variable in Static Blocks  <\/h2>\n<p>Static blocks can access <code>static variables<\/code> since <code>static variables<\/code> are initialized before the execution of a static block.  <\/p>\n<p>Update <code>Laptop.java<\/code> Class and add the following code:<\/p>\n<pre class=\"brush:java\">   \/\/ static block  can access static variables  \n    static {\n    \t\n    \tSystem.out.println(\"motherboard: \"+motherboard);\n    \t\n    }\n<\/pre>\n<p>Now run the <code>StaticVariableExample1.java<\/code> Class <\/p>\n<p><span style=\"text-decoration: underline\"><em>Example Output<\/em><\/span><\/p>\n<pre class=\"brush:bash\">motherboard : ASUS\nlaptop1  motherboard:ASUS cpu:i5 monitor_dimension:15 inch storage:500 gb\nlaptop2  motherboard:ASUS cpu:i3 monitor_dimension:17 inch storage:1 tb\nlaptop1  motherboard:GIGABYTE cpu:i5 monitor_dimension:15 inch storage:500 gb\nlaptop2  motherboard:GIGABYTE cpu:i3 monitor_dimension:17 inch storage:1 tb\n<\/pre>\n<p>In the above example, we saw that when the static block runs can access and print the <code>static variable<\/code>. <\/p>\n<h2 class=\"wp-block-heading\">4. Static Methods<\/h2>\n<p>The <code>static variables<\/code> can also be accessed inside static methods.<\/p>\n<p> Update <code>Laptop.java<\/code> Class and add the following code: <\/p>\n<p><span style=\"text-decoration: underline\"><em>Laptop.java<\/em><\/span><\/p>\n<pre class=\"brush:java;highlight:[26,27,28,29,30,31]\">package com.javacodegeeks;\n\/**\n * @author Petros Koulianos\n *\n *\/\npublic class Laptop {\n       \n    \/\/static variable \n    public static String motherboard = \"ASUS\";\n     \n    public String cpu ;\n     \n    public String monitor_dimension ;\n     \n    public String storage ;\n     \n   \/\/ static block  can access static variables \n\t\n\t  static {\n\t  \n\t  System.out.println(\"static block motherboard : \"+motherboard);\n\t  \n\t  }\n\t \n    \n    \/\/This is a Static Methods access static variables \n    static void motherboardname(){\n    \t\n        System.out.println(\"static method motherboard : \"+motherboard);\n        \n    }\n    \n\n \n}\n<\/pre>\n<p> Update <code>StaticVariableExample1.java<\/code> Class and add the following code: <\/p>\n<p><span style=\"text-decoration: underline\"><em>StaticVariableExample1 .java<\/em><\/span><\/p>\n<pre class=\"brush:java;highlight:[12]\">package com.javacodegeeks;\n \n\/**\n * @author Petros Koulianos\n *\n *\/\npublic class StaticVariableExample1 {\n     \n \n    public static void main(String[] args) {\n         \n    \tLaptop.motherboardname();\n    \t\n        Laptop laptop1 = new Laptop();\n         \n        laptop1.cpu = \"i5\";\n         \n        laptop1.monitor_dimension = \"15 inch\";\n         \n        laptop1.storage = \"500 gb\";\n         \n        Laptop laptop2 = new Laptop();\n         \n        laptop2.cpu = \"i3\";\n         \n        laptop2.monitor_dimension = \"17 inch\";\n         \n        laptop2.storage = \"1 tb\";\n         \n        \/\/static variables can be access with Class name or with instance name\n        \/\/preferred way is to refer with Class name\n        System.out.println(\"laptop1  motherboard:\"+Laptop.motherboard+\" cpu:\"+laptop1.cpu+\" monitor_dimension:\"+laptop1.monitor_dimension+\" storage:\"+laptop1.storage);\n         \n        System.out.println(\"laptop2  motherboard:\"+laptop2.motherboard+\" cpu:\"+laptop2.cpu+\" monitor_dimension:\"+laptop2.monitor_dimension+\" storage:\"+laptop2.storage);\n         \n        \/\/ The company has change the motherboard\n        Laptop.motherboard = \"GIGABYTE\";\n         \n         \n        System.out.println(\"laptop1  motherboard:\"+Laptop.motherboard+\" cpu:\"+laptop1.cpu+\" monitor_dimension:\"+laptop1.monitor_dimension+\" storage:\"+laptop1.storage);\n         \n        System.out.println(\"laptop2  motherboard:\"+laptop2.motherboard+\" cpu:\"+laptop2.cpu+\" monitor_dimension:\"+laptop2.monitor_dimension+\" storage:\"+laptop2.storage);\n \n    }\n     \n \n}\n<\/pre>\n<p>Now run the <code>StaticVariableExample1.java<\/code> Class <\/p>\n<p><span style=\"text-decoration: underline\"><em>Example Output<\/em><\/span><\/p>\n<pre class=\"brush:bash\">static block motherboard : ASUS\nstatic method motherboard : ASUS\nlaptop1  motherboard:ASUS cpu:i5 monitor_dimension:15 inch storage:500 gb\nlaptop2  motherboard:ASUS cpu:i3 monitor_dimension:17 inch storage:1 tb\nlaptop1  motherboard:GIGABYTE cpu:i5 monitor_dimension:15 inch storage:500 gb\nlaptop2  motherboard:GIGABYTE cpu:i3 monitor_dimension:17 inch storage:1 tb\n<\/pre>\n<h2 class=\"wp-block-heading\">5. Static final variables <\/h2>\n<p>It is very common to combine <code>static variables<\/code> with the final modifier to declare constants. Keep in mind that by convention <a href=\"http:\/\/docs.oracle.com\/javase\/tutorial\/java\/javaOO\/classvars.html\">final static values<\/a> are spelled in uppercase letters .<\/p>\n<pre class=\"brush:java\">    \/\/final static variable \n    public final static String COMPANY =\"FOO Company\";\n<\/pre>\n<h2 class=\"wp-block-heading\">6. Static variables and  Multithreading  <\/h2>\n<p>\u0399t is very important to know that <strong>static variables<\/strong> are <strong>not Thread-Safe.<\/strong>  This means if 2 or more threads modify the same <code>static variable<\/code>, unexpected and multiple malfunctions can be caused (ex. dead locks etc) .<\/p>\n<p> Create a class with name <code>StaticVariableExample2<\/code> and paste the following code : <\/p>\n<p><span style=\"text-decoration: underline\"><em>StaticVariableExample2.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks;\n\n\/**\n * @author Petros Koulianos\n *\n *\/\n\npublic class StaticVariableExample2 {\n\n\tstatic int counter = 10;\n\t\n\tpublic static void main(String[] args) {\n\t\t\n\t\t\/\/launch first thread with step= -1\n\t\tnewThread(\"first thread\",500,1);\n\t\t\n\t\t\n\t\t\/\/launch second thread with step= -3\n\t\tnewThread(\"second thread\",250,3);\n\t\t\n\t}\n\t\n\tpublic static void newThread(String name , int sleep , int step) {\n\t\t\n\t\tThread th = new Thread() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\t\n\t\t\t\twhile(counter != 0) {\n\t\t\t\t\t\n\t\t\t\t\tSystem.out.println(\"**\"+name+\"** counter:\"+counter);\n\t\t\t\t\t\n\t\t\t\t\tcounter = counter - step;\n\t\t\t\t\t\n\t\t\t\t\ttry {\n\t\t\t\t\t\t\/\/sleep the thread to slow down the execution\n\t\t\t\t\t\tThread.sleep(sleep);\n\t\t\t\t\t\t\n\t\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t\t\t\n\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t};\n\t\t\n\t\tth.start();\n\t}\n\n}\n\n<\/pre>\n<p><span style=\"text-decoration: underline\"><em>Example Output<\/em><\/span><\/p>\n<pre class=\"brush:bash\">**second thread** counter:10\n**first thread** counter:10\n**second thread** counter:6\n**second thread** counter:3\n**first thread** counter:3\n**second thread** counter:-1\n**first thread** counter:-4\n**second thread** counter:-4\n**second thread** counter:-8\n**first thread** counter:-11\n**second thread** counter:-11\n**second thread** counter:-15\n**first thread** counter:-18\n**second thread** counter:-19\n**second thread** counter:-22\n**first thread** counter:-25\n**second thread** counter:-26\n**second thread** counter:-29\n**first thread** counter:-32\n**second thread** counter:-33\n............................\n<\/pre>\n<p>The above example runs 2 separate threads that modify the same <code>static variable<\/code> differently and the result is to fall both threads into a&nbsp;<strong>deadlock.<\/strong><\/p>\n<h2 class=\"wp-block-heading\">7. Download the Source Code<\/h2>\n<p>This was a <code>Static variable<\/code> Java example.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/JavaStaticVariable.zip\"><strong>Static Variable Java Example<\/strong><\/a><\/div>\n<p><strong>Last updated on Sept. 10, 2019<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction This is a static variable Java Example. Static variables are declared with the static word before the type of variable. The main difference among regular variables is that static variables are not bounded by any object instances, and are shared among all instances. static datatype Variable \/\/static variable example static int count = &hellip;<\/p>\n","protected":false},"author":191,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[54],"tags":[212,1056],"class_list":["post-98","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-statics","tag-java-basics-2","tag-statics"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Static Variable Java Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn more? Then check out our detailed Static Variable Java example!Variables in a class that are the same for all instances of the class.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Static Variable Java Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more? Then check out our detailed Static Variable Java example!Variables in a class that are the same for all instances of the class.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2012-11-11T19:19:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-05-15T15:45:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Petros Koulianos\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Petros Koulianos\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/\"},\"author\":{\"name\":\"Petros Koulianos\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/3e2624eaac12f3a0de10922846593fe3\"},\"headline\":\"Static Variable Java Example\",\"datePublished\":\"2012-11-11T19:19:46+00:00\",\"dateModified\":\"2020-05-15T15:45:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/\"},\"wordCount\":328,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"keywords\":[\"java basics\",\"statics\"],\"articleSection\":[\"statics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/\",\"name\":\"Static Variable Java Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2012-11-11T19:19:46+00:00\",\"dateModified\":\"2020-05-15T15:45:13+00:00\",\"description\":\"Interested to learn more? Then check out our detailed Static Variable Java example!Variables in a class that are the same for all instances of the class.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Java Basics\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/java-basics\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"statics\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/java-basics\/statics\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Static Variable Java Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/3e2624eaac12f3a0de10922846593fe3\",\"name\":\"Petros Koulianos\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2019\/08\/petros.koulianos-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2019\/08\/petros.koulianos-96x96.jpg\",\"caption\":\"Petros Koulianos\"},\"description\":\"Petros studied Computer Science in Hellenic Open University . He is an experienced administrator with a demonstrated history of working in the health information technology systems and health services industry. Skilled in Oracle Databases, HL7 Standards, Health Information Systems (HIS), Laboratory Information Systems (LIS) . In his free time designs and develop apps in Java , Android and node.js .\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/petros-koulianos-ba9a91165\/\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/petros-koulianos\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Static Variable Java Example - Java Code Geeks","description":"Interested to learn more? Then check out our detailed Static Variable Java example!Variables in a class that are the same for all instances of the class.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/","og_locale":"en_US","og_type":"article","og_title":"Static Variable Java Example - Java Code Geeks","og_description":"Interested to learn more? Then check out our detailed Static Variable Java example!Variables in a class that are the same for all instances of the class.","og_url":"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-11-11T19:19:46+00:00","article_modified_time":"2020-05-15T15:45:13+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Petros Koulianos","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Petros Koulianos","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/"},"author":{"name":"Petros Koulianos","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/3e2624eaac12f3a0de10922846593fe3"},"headline":"Static Variable Java Example","datePublished":"2012-11-11T19:19:46+00:00","dateModified":"2020-05-15T15:45:13+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/"},"wordCount":328,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","keywords":["java basics","statics"],"articleSection":["statics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/","url":"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/","name":"Static Variable Java Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2012-11-11T19:19:46+00:00","dateModified":"2020-05-15T15:45:13+00:00","description":"Interested to learn more? Then check out our detailed Static Variable Java example!Variables in a class that are the same for all instances of the class.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/static-variable-java-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Java Basics","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/java-basics\/"},{"@type":"ListItem","position":4,"name":"statics","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/java-basics\/statics\/"},{"@type":"ListItem","position":5,"name":"Static Variable Java Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/3e2624eaac12f3a0de10922846593fe3","name":"Petros Koulianos","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2019\/08\/petros.koulianos-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2019\/08\/petros.koulianos-96x96.jpg","caption":"Petros Koulianos"},"description":"Petros studied Computer Science in Hellenic Open University . He is an experienced administrator with a demonstrated history of working in the health information technology systems and health services industry. Skilled in Oracle Databases, HL7 Standards, Health Information Systems (HIS), Laboratory Information Systems (LIS) . In his free time designs and develop apps in Java , Android and node.js .","sameAs":["https:\/\/www.linkedin.com\/in\/petros-koulianos-ba9a91165\/"],"url":"https:\/\/examples.javacodegeeks.com\/author\/petros-koulianos\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/98","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/191"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=98"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/98\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}