{"id":14069,"date":"2020-03-30T19:56:53","date_gmt":"2020-03-31T02:56:53","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=14069"},"modified":"2023-12-01T02:36:05","modified_gmt":"2023-12-01T10:36:05","slug":"java-static","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/java-static\/","title":{"rendered":"Java Static"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">How to Use the Java Static Keyword<\/h2>\n\n\n\n<p>When you\u2019re working with classes in Java, you usually need to create an instance of the class before you can access its members. However, you may encounter a situation where you want to define a class member without creating an instance of a class.<\/p>\n\n\n\n<p>That\u2019s where the Java static keyword comes in. The Java static keyword is used to define class members that you can access without creating an instance of a class.<\/p>\n\n\n\n<p>This tutorial will discuss, with examples, the basics of the Java static keyword and how to use it in your Java programs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java Classes<\/h2>\n\n\n\n<p>In Java, classes are blueprints for an object. For example, a class called OrderCoffee could include all the functions related to ordering a coffee, such as placing an order, changing an existing order, and adding new items to an order.<\/p>\n\n\n\n<p>We can then create objects that are instances of that class. For example, an object called CoffeeOrder12 could use the blueprint from the CoffeeOrder class to store data for an individual coffee order. The CoffeeOrder12 object would have access to all the functions and methods declared within the CoffeeOrder class. See Image 1 for a visual representation of these ideas.<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/docs.google.com\/drawings\/u\/0\/d\/sRw2OlMn1AmbbA0ZWRC23IA\/image?w=229&amp;h=215&amp;rev=8&amp;ac=1&amp;parent=1g8uSQtregD01GofHmODeLs1VpV114D6T3fqdmWDAYP4\" alt=\"\"\/><figcaption class=\"wp-element-caption\"> Image 1: Classes, instances, and functions. <\/figcaption><\/figure>\n\n\n\n<p>Now that we\u2019ve discussed the basics of Java classes, we can move on to exploring the Java static keyword.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java Static Methods<\/h2>\n\n\n\n<p>Static methods, also known as class methods, are methods that belong to a class and not its instances. Because static methods belong to a class, you can only invoke the method from the class itself, and not from an object of the class.<\/p>\n\n\n\n<p>Here\u2019s the syntax for invoking a static method:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Class.methodName();<\/pre><\/div>\n\n\n\n<p>Let\u2019s look at an example to see how this works.<\/p>\n\n\n\n<p>Suppose we are creating a program that manages the orders for a coffee store. We want to create a class called CoffeeOrder that stores all the functions for ordering a coffee.<\/p>\n\n\n\n<p>We decide that we want to be able to print new order notifications to the barista\u2019s console. We want this new order notification to be static because it is not dependent on any other code in the coffee order object. We can use the following code to accomplish this task:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class CoffeeOrder {\n\tint createOrder() {\n\t\t\/\/ Code here\n\t\tint orderNumber = 92;\n\t\treturn orderNumber;\n\t}\n\tstatic void printOrder(int order) {\n\t\tSystem.out.println(\"Order #\" + order + \" order has been placed.\");\n\t}\n}\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tCoffeeOrder order92 = new CoffeeOrder();\n\t\tint number = order92.createOrder();\n\t\tSystem.out.println(\"Order number: \" + number);\n\t\tCoffeeOrder.printOrder(number);\n\t}\n}<\/pre><\/div>\n\n\n\n<p>Our code returns: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Order number: 92\nOrder #92 has been placed.<\/pre><\/div>\n\n\n\n<p>Let\u2019s break down our code step by step. First we declare a class called CoffeeOrder. CoffeeOrder contains two methods: <code>createOrder()<\/code> and <code>printOrder()<\/code>.<\/p>\n\n\n\n<p><code>createOrder()<\/code> is a regular method that creates an order and returns an order number. <code>printOrder()<\/code> is a static method that prints a message to the console notifying the barista that a new order has been placed.<\/p>\n\n\n\n<p>In our main program, we create an object of CoffeeOrder called order92. This object stores the data for order #92. Then we use the <code>createOrder()<\/code> method to get an order number, and we print out that order number, preceded by Order number: , to the console.<\/p>\n\n\n\n<p>When we invoke the <code>createOrder()<\/code> method, we use <code>order92.createOrder()<\/code>. This is because <code>createOrder()<\/code> is not a static method, so we can access it when manipulating our object.<\/p>\n\n\n\n<p>At the end of our main code, we use <code>CoffeeOrder.printOrder()<\/code> to print a message stating Order #[order number] order has been placed. to the console. In this message, <code>order number<\/code> is equal to the number associated with a specific order. Because <code>printOrder()<\/code> is a static method, we have to use CoffeeOrder (our class) to access it.<\/p>\n\n\n\n<p>If we tried to use <code>order92.printOrder()<\/code> (which invokes an instance of our class), like we did when we used the <code>createOrder()<\/code> method, our could would give us a warning.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java Static Variables<\/h2>\n\n\n\n<p>The static keyword in Java can also be used to create static instance variables. Static variables belong to a class and are initialized only once, at the start of a program\u2019s execution.<\/p>\n\n\n\n<p>Static variables do not belong to an object. This means that in order to access them you need to reference the relevant class. Here\u2019s the syntax to declare a static variable in Java:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>static String COFFEE_NAME = \"Espresso\";<\/pre><\/div>\n\n\n\n<p>In this example, we declared a static variable called COFFEE_NAME, to which we assigned the string value Espresso.<\/p>\n\n\n\n<p>Let\u2019s walk through an example to showcase a Java static variable in use.<\/p>\n\n\n\n<p>Suppose we are creating a program that processes orders at a coffee shop. This program should store the number of baristas on duty, and when an order is created, the program should associate that order with the name of the barista who will prepare that order.<\/p>\n\n\n\n<p>We could use this code to create our coffee processing program:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class CoffeeOrder {\n\tint baristasOnDuty = 2;\n\tstatic String name = \"Hannah Johnson\";\n\tpublic static void main(String[] args) {\n\t\tCoffeeOrder order111 = new CoffeeOrder();\n\t\tSystem.out.println(\"Baristas on duty: \" + baristasOnDuty);\n\t\tSystem.out.println(\"Assigned barista: \" + order111.name);\n\t}\n}<\/pre><\/div>\n\n\n\n<p>Our code returns: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Baristas on duty: 2\nAssigned barista: Hannah Johnson<\/pre><\/div>\n\n\n\n<p>In our code, we declare the following two variables:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>baristasOnDuty. This is a standard variable, which means that it can be accessed throughout our class.<\/li>\n\n\n\n<li>name. This is a static variable, which means we need to reference the object with which it is associated to retrieve its value.<\/li>\n<\/ul>\n\n\n\n<p>In our main program, we create an instance of the CoffeeOrder class and call it order111. We then print out the message Baristas on duty: &nbsp;followed by the contents of the baristasOnDuty variable. Because this is a standard variable, we don\u2019t need to reference its class name.<\/p>\n\n\n\n<p>On the next line of our code, we print the message Assigned barista: &nbsp;to the console, followed by the name of the barista to whom the order is assigned. However, the barista\u2019s name is stored as a static variable.<\/p>\n\n\n\n<p>This means that, in order to retrieve the name of the barista, we need to reference the name of the object with which that variable is associated. In this case, we use order111.name to retrieve the barista\u2019s name. This is because the variable name is static and therefore can only be accessed when referencing the order111 object.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java Static Block<\/h2>\n\n\n\n<p>The Java static keyword can also be used to create a static block. If a class has different static variables that need to be initialized individually, then you should use a static block.<\/p>\n\n\n\n<p>Static blocks are executed once\u2014when the class is first loaded into the computer\u2019s memory. Here\u2019s the syntax for a static block of code in Java:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>static {\n\t\/\/ Code here\n}<\/pre><\/div>\n\n\n\n<p>Let\u2019s walk through an example to demonstrate how a static block works. Suppose we are asked to make the message <code>A new order is incoming \u2026<\/code> print to the console before the program assigns the order to a barista so the baristas know to prepare. We could do so by creating a static class. The static class will run the first time the program is executed.<\/p>\n\n\n\n<p>Here\u2019s an example of a static class that prints out the aforementioned message, then assigns an order to a barista:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class CoffeeOrder {\n\tint baristasOnDuty = 2;\n\tstatic String name = \"Hannah Johnson\";\n\tstatic {\n\t\tSystem.out.println(\"A new order is incoming \u2026\");\n\t}\n\tpublic static void main(String[] args) {\n\t\tCoffeeOrder order111 = new CoffeeOrder();\n\t\tSystem.out.println(\"Baristas on duty: \" + baristasOnDuty);\n\t\tSystem.out.println(\"Assigned barista: \" + order111.name);\n\t}\n}<\/pre><\/div>\n\n\n\n<p>Our code returns: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>A new order is incoming \u2026\nBaristas on duty: 2\nAssigned barista: Hannah Johnson<\/pre><\/div>\n\n\n\n<p>In our code, we first initialized baristasOnDuty and name variables. Then the program printed the message A new order is incoming \u2026 to the console. This message was stored within our static block of code. After the program executed the contents of the static block, it ran our main program, which returned the same output as the main program from our last example.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The Java static keyword has a number of uses. You can use the static keyword to create static methods, static variables, and static blocks of code.<\/p>\n\n\n\n<p>This tutorial walked through, with examples, the basics of the static keyword and how you can use the static keyword with methods, variables, and code blocks. After reading this tutorial, you are ready to start using the Java static keyword like a pro.<\/p>\n","protected":false},"excerpt":{"rendered":"How to Use the Java Static Keyword When you\u2019re working with classes in Java, you usually need to create an instance of the class before you can access its members. However, you may encounter a situation where you want to define a class member without creating an instance of a class. That\u2019s where the Java&hellip;","protected":false},"author":240,"featured_media":14070,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17289],"tags":[],"class_list":{"0":"post-14069","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-java"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Java","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":"","is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Java Static: The Complete Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"Developers use the Java static keyword to create class members that can be accessed without generating an instance of a class. On Career Karma, discover how to use the static keyword.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/java-static\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Static\" \/>\n<meta property=\"og:description\" content=\"Developers use the Java static keyword to create class members that can be accessed without generating an instance of a class. On Career Karma, discover how to use the static keyword.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/java-static\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-31T02:56:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T10:36:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/group-oo-people-having-a-meeting-1367276-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"680\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-static\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-static\\\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Java Static\",\"datePublished\":\"2020-03-31T02:56:53+00:00\",\"dateModified\":\"2023-12-01T10:36:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-static\\\/\"},\"wordCount\":1225,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-static\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/group-oo-people-having-a-meeting-1367276-1.jpg\",\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-static\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-static\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-static\\\/\",\"name\":\"Java Static: The Complete Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-static\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-static\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/group-oo-people-having-a-meeting-1367276-1.jpg\",\"datePublished\":\"2020-03-31T02:56:53+00:00\",\"dateModified\":\"2023-12-01T10:36:05+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"Developers use the Java static keyword to create class members that can be accessed without generating an instance of a class. On Career Karma, discover how to use the static keyword.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-static\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-static\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-static\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/group-oo-people-having-a-meeting-1367276-1.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/group-oo-people-having-a-meeting-1367276-1.jpg\",\"width\":1020,\"height\":680},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-static\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Java Static\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/author\\\/jamesgallagher\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Java Static: The Complete Guide | Career Karma","description":"Developers use the Java static keyword to create class members that can be accessed without generating an instance of a class. On Career Karma, discover how to use the static keyword.","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:\/\/careerkarma.com\/blog\/java-static\/","og_locale":"en_US","og_type":"article","og_title":"Java Static","og_description":"Developers use the Java static keyword to create class members that can be accessed without generating an instance of a class. On Career Karma, discover how to use the static keyword.","og_url":"https:\/\/careerkarma.com\/blog\/java-static\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-03-31T02:56:53+00:00","article_modified_time":"2023-12-01T10:36:05+00:00","og_image":[{"width":1020,"height":680,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/group-oo-people-having-a-meeting-1367276-1.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/java-static\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/java-static\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Java Static","datePublished":"2020-03-31T02:56:53+00:00","dateModified":"2023-12-01T10:36:05+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-static\/"},"wordCount":1225,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-static\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/group-oo-people-having-a-meeting-1367276-1.jpg","articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/java-static\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/java-static\/","url":"https:\/\/careerkarma.com\/blog\/java-static\/","name":"Java Static: The Complete Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-static\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-static\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/group-oo-people-having-a-meeting-1367276-1.jpg","datePublished":"2020-03-31T02:56:53+00:00","dateModified":"2023-12-01T10:36:05+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"Developers use the Java static keyword to create class members that can be accessed without generating an instance of a class. On Career Karma, discover how to use the static keyword.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/java-static\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/java-static\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/java-static\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/group-oo-people-having-a-meeting-1367276-1.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/group-oo-people-having-a-meeting-1367276-1.jpg","width":1020,"height":680},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/java-static\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/careerkarma.com\/blog\/java\/"},{"@type":"ListItem","position":3,"name":"Java Static"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/14069","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=14069"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/14069\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/14070"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=14069"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=14069"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=14069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}