How to use libraries for Algorithms part I Coursera course in Eclipse(如何在 Eclipse 中使用库进行算法第一部分 Coursera 课程)
问题描述
我已经开始 Coursera )
问.如果我使用命名包来构造我的代码,编译器将无法再访问 stdlib.jar 或 algs4.jar 中的库.为什么不呢?
A.stdlib.jar 和 algs4.jar 中的库位于默认"包中.在 Java 中,您不能从命名包访问默认包中的类.如果您需要将我们的库与命名包一起使用,您可以使用以下包版本:stdlib-package.jar 和 algs4-package.jar.
警告:如果您正在学习 Princeton COS 226 或 Coursera, Algorithms, Part I 或 II,您必须使用我们图书馆的默认软件包版本以方便评分.
显示我的测试成功:
I've started Coursera Algorythms course. Practice assignments must be done on Java and they suggest using DrJava as IDE, but it's really unconvenient. So I'd like to use Eclipse, but the problem is that I couldn't use 2 libraries(algs4.jar and stdlib.jar), which are provided for this course. After doing steps from this guide I was able to include them in my project:
but when I try to use their classes in my project, Eclipse doesn't allow to do it, and I couldn't import them by Ctrl + Space:
And even when I am trying directly import class like import stdlib.StdRandom;
it still doesn't work.
What can I do to make it work properly?
Why don't you use these two JARs—— stdlib-package.jar and algs4-package.jar.
And below the code page(http://algs4.cs.princeton.edu/code/)
Q. If I use a named package to structure my code, the compiler can no longer access the libraries in stdlib.jar or algs4.jar. Why not?
A. The libraries in stdlib.jar and algs4.jar are in the "default" package. In Java, you can't access classes in the default package from a named package. If you need to use our libraries with a named package, you can use these package versions: stdlib-package.jar and algs4-package.jar.
Warning: if you are taking Princeton COS 226 or Coursera, Algorithms, Part I or II, you must use the default package verison of our libraries to facilitate grading.
Showing my test success:
这篇关于如何在 Eclipse 中使用库进行算法第一部分 Coursera 课程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Eclipse 中使用库进行算法第一部分 Coursera 课程
基础教程推荐
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 降序排序:Java Map 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01