Skip to content

Missing imports in the sample code of the "Project Explorer" section of the "Building a Java application in Visual Studio Code" tutorial #207

@brlin-tw

Description

@brlin-tw

In the following sample code of the "Project Explorer" section of the "Building a Java application in Visual Studio Code" tutorial:

public class Concatenate {

    public static void main(String[] args) {

        if (args.length < 2) {
            IO.println("You need to provide 2 lists as arguments. You provided " + args.length);
            throw new UnsupportedOperationException("You need to provide 2 lists as arguments");
        }

    // stripped...

}

lacks the following class imports:

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

which will result in the following compilation errors when the reader tries to run or debug the main code:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project concatenate: Compilation failure: Compilation failure:
org/yourcompany/yourproject/Concatenate.java:[27,55] cannot find symbol
  symbol:   class List
  location: class Concatenate
org/yourcompany/yourproject/Concatenate.java:[15,37] cannot find symbol
  symbol:   variable List
  location: class Concatenate
org/yourcompany/yourproject/Concatenate.java:[16,48] cannot find symbol
  symbol:   variable Collectors
  location: class Concatenate
org/yourcompany/yourproject/Concatenate.java:[19,48] cannot find symbol
  symbol:   variable Collectors
  location: class Concatenate
org/yourcompany/yourproject/Concatenate.java:[28,9] cannot find symbol
  symbol:   class Set
  location: class Concatenate
org/yourcompany/yourproject/Concatenate.java:[28,41] cannot find symbol
  symbol:   class HashSet
  location: class Concatenate

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions