- Код правильно указан в разделе "ссылки на библиотеки" [/b] на панели проектов Java.
Код: Выделить всё
algs4.jar) находится в папке источника, которая указана в java.project.sourcepaths .Код: Выделить всё
Arithmetic.java - Я открываю корневую папку рабочей области (
Код: Выделить всё
cs61b/< /code>), который содержит все, включая: < /p> .vscode/settings.json -
Код: Выделить всё
library-sp25/algs4.jar -
Код: Выделить всё
lab1/lab01/src/Arithmetic.java
Вот мой.
Код: Выделить всё
{
"java.project.sourcePaths": [
"lab1/lab01/src"
],
"java.project.referencedLibraries": [
"library-sp25/algs4.jar"
]
}
Я попытался переключить режим языкового сервера Java на стандартный, все еще не работает. < /p>
Исходный код : < /p>
Код: Выделить всё
import edu.princeton.cs.algs4.StdIn;
/** Simple Arithmetic Class.
* @author Josh Hug
* */
public class Arithmetic {
/** Computes product of two ints.
* @param a Value 1
* @param b Value 2
* @return Product of a and b
* */
public static int product(int a, int b) {
return a * b;
}
/** Computes sum of two ints (incorrectly).
* @param a Value 1
* @param b Value 2
* @return Sum of a and b
* */
public static int sum(int a, int b) {
return a * b;
}
public static void main(String[] args) {
System.out.println("Give me a number! (no decimals, please)");
int num1 = StdIn.readInt();
System.out.println("Give me another number! (still no decimals)");
int num2 = StdIn.readInt();
System.out.println("The product of " + num1 + " and " + num2 + " is: " + product(num1, num2));
System.out.println("The sum of " + num1 + " and " + num2 + " is: " + sum(num1, num2));
}
}
< /code>
Сообщение об ошибке: < /p>
[{
"resource": "/e:/coding/cs61b/lab1/lab01/src/Arithmetic.java",
"owner": "_generated_diagnostic_collection_name_#1",
"code": "errors(1): 1:8-1:11",
"severity": 8,
"message": "package edu.princeton.cs.algs4 does not exist",
"startLineNumber": 1,
"startColumn": 8,
"endLineNumber": 1,
"endColumn": 11,
"origin": "extHost1"
}]
edit:
Подробнее здесь: https://stackoverflow.com/questions/797 ... va-package