Understanding Java: The Non-Access Modifier: Static


June 23, 2023

5Minute Read

Author: Bryce Marshall – Student Blog Series

Why You Can’t Make a Static Reference to a Non-Static [Fill in the Blank]: Explained

If you are wondering why you, “can not make static reference to non-static [fill in the blank]”? Here’s why.

The Java language utilizes what are called modifiers, namely access and non-access types. These modifiers are keywords that allow us to modify our classes by fine-tuning the accessibility of their members. The five members of a class are variables (states), methods (behaviors), constructors, blocks, and inner classes.

Demystifying the Static Keyword in Java: A Guide for Beginners

The static keyword in Java is a non-access modifier. The static modifier makes a member (variables or methods) of a class independent of the objects of the class and is used when we are defining properties that are common to all objects in the class. Static variables are shared among all objects/instances within the class and can be accessed without reference to any object/instance. Static methods can only use static variables and call static methods.

Objects, Instances, and Classes in Java: What’s the Difference?

Briefly, objects have a state (variables) and behavior (methods), and classes are the blueprints representing the properties or characteristics of the object. Objects and instances are very similar, and here is an example to illustrate the difference. Pretend that you have a basket of 6 oranges, and a class named Orange that will represent the real oranges in your basket. This class Orange, has the member variables size, shape, and color to represent characteristics of the object, an orange.

The Importance of Defining Objects in Java: Explained with Oranges

The object is an orange, and an instance represents each individual instance of an orange, such as orange1, orange2, etc. In other words, an instance is a copy or reference to the object itself at the particular time that it is instantiated. Objects are the definitions (states and behaviors), while instances are the physical things. You must define an orange before you can make copies of it.

Understanding the Limitations of Static Methods in Java

The moral of the story is that a non-static member cannot be referred to from a static method, and a static method cannot access a non-static method or variable.

Start Your Journey Today

Interested in changing careers and becoming a software developer? Learn more about Promineo Tech’s programs and how we help students make this transition through affordable, low-risk technology education: https://promineotech.com/programs/back-end-development/

Related Articles

12 Minute Read

24 Pro Tips for Balancing Full-Time Work and a Coding Bootcamp

You’re already juggling the demands of a full-time job, and now you’re adding a coding bootcamp into the mix. Sounds challenging, right? Well, you’re not alone. Most people who choose to take online coding bootcamps to improve their skills find themselves in a similar situation.  Coding bootcamps have become increasingly popular in recent years as […]

5 Minute Read

The Flexibility of Coding Bootcamps for Full-Time Workers

Are you a full-time worker that feels stuck in your current career?   Many people in your position find themselves at a crossroads, yearning for something more, but feel trapped by the demands of a 9-to-5 job—which can often leave little room for pursuing a new path.   However, there’s hope: coding bootcamps.   In this blog […]

8 Minute Read

Student Spotlight: Jolene Melanson

In high school, people called Jolene Melanson “bossy.” But, her classmates never objected to being in her group projects. After all, she knew how to lead and get everyone an A.   She’s taken these natural-born leadership skills with her throughout her post-high school career, too. Whether as a Tech Consultant at Target or a Team […]

In the News

Check out Promineo Tech in the news.