Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7995499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:25:59+00:00 2026-06-04T14:25:59+00:00

I don’t understand the meaning of the keyword static when I import System class:

  • 0

I don’t understand the meaning of the keyword static when I import System class:

import static java.lang.System.*

I’m reading the book about Java and it’s written there:

Any import declaration that doesn’t use the word static must start
with the name of a package and must end with either of the following:

  • The name of a class within that package
  • An asterisk (indicating all classes within that package)

For example, the declaration import java.util.Scanner; is valid
because java.util is the name of a package in the Java API, and
Scanner is the name of a class in the java.util package.

Here’s another example. The declaration import javax.swing.*; is valid
because javax.swing is the name of a package in the Java API, and the
asterisk refers to all classes in the javax.swing package.

And I have the following code:

public class Addition {

   public static void main(String[] args) {
      double num;
      num = 100.53;

      num = num + 1000;

      // So when I want to import the whole package java.lang as written in the book, it doesn't work:
      // import java.lang.*;
      // or like this:
      // import static java.lang.*;
      // NetBeans in both cases doesn't see these abbreviated names `out` and throws errors. Why?
      out.print("The result is ");
      out.print(num);
      out.println(" .");
   }
}

And it works when I import this way:

import static java.lang.System.out;
import static java.lang.System.*

But doesn’t work when I try do this:

import java.lang.System.out;
import java.lang.System.*

What’s the meaning of the static keyword in this particular case?

And why import java.lang.*; doesn’t import the whole package with System class in it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:26:01+00:00Added an answer on June 4, 2026 at 2:26 pm

    A static import allows you to write this:

    out.print("The result is ");
    

    rather than this:

    System.out.print("The result is ");
    

    See e.g. http://docs.oracle.com/javase/1.5.0/docs/guide/language/static-import.html.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

don't know if the title describes anything about what I'm trying to say but
Don't think that I'm mad, I understand how php works! That being said. I
Don't know a whole lot about streams. Why does the first version work using
I don't have much knowledge about the IPv6 protocol, so sorry if the question
Don't know if it matters, but the msg.d is about 300 rows long. I
Don't understand this simple code: def main(): print (This program illustrates a chaotic function)
Don't get me wrong PDO is great but what I don't like about it,
don't understand: in my controller: @json = User.all.to_gmaps4rails do |user| \Title\: \#{user.email}\ end in
Don't understand, if Data.Map is and [] is. I found this out while wondering
Don't know much about encryption... Say I'm preparing a SAML request to submit to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.