0

I used to work on 'IntelliJ Idea community' where I used to create new projects and files and it automatically packaged each newly created file. Now I started to code on 'VS Code' where I have to do all the stuff manually. Recently I created a folder named "VS_Code" and created a dozen of .java files in it. I tried to use package VS_Code; in each file to put them in a single package but it suggests,

The declared package "VS_Code" does not match the expected package ""

I might not know how to use 'package'. Please help me.

3
  • hi & welcome! :-) "Package" means the folder(structure) relatively to a "source root". Commented Nov 18, 2021 at 11:24
  • In your case it seems, you declared package VS_Code;, but the (source) files are located in the "source root" (so VS_Code, that's why "he" proposes package ""(<root)).. 2. upper case letters(+many others) are not allowed in "package". Commented Nov 18, 2021 at 11:32
  • solution: create a folder: VS_Code/mypackage, move all java files there, replace (in all files) package VS_Code with package mypackage. Commented Nov 18, 2021 at 11:34

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.