Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

265
Visualizações
Import declaration

I'm reading the Java 8 specification to better understand the Java language.

Specifically, the Chapter 7 Packages.

However in 7.5.2 7.5.2 Type-Import-on-Demand Declarations I don't understand the case where we can use TypeName according to the following syntax:

import PackageOrTypeName . * ;

The specification says:

If the PackageOrTypeName denotes a type (§6.5.4), then the name must be qualified (§6.5.5.2), or a compile-time error occurs.

So I jump to 6.5.4 but the following is very unclear:

If the PackageOrTypeName, Q, occurs in the scope of a type named Q, then the PackageOrTypeName is reclassified as a TypeName. Otherwise, the PackageOrTypeName is reclassified as a PackageName. The meaning of the PackageOrTypeName is the meaning of the reclassified name.

So I can't imagine how to use TypeName.

Please, can anyone provide me with an example to import types with * with TypeName?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You seem to be forgetting about nested classes. An example would be:

import java.util.Map.*;

Which would import Entry. It can now be used like this (unqualified):

Entry<String, String> e = ...;

Another way to do this import is:

import java.util.Map.Entry;

Where java.util.Map is the name of a type.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda