如何使用库的算法第一部分在Coursera课程在Eclipse [英] How to use libraries for Algorithms part I Coursera course in Eclipse

查看:133
本文介绍了如何使用库的算法第一部分在Coursera课程在Eclipse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经启动了Coursera )



Q。如果我使用命名包来构造我的代码,编译器就不能再访问stdlib.jar或algs4.jar中的库。为什么不呢?



A。 stdlib.jar和algs4.jar中的库位于默认包中。在Java中,您无法从命名的包中访问默认包中的类。如果您需要使用命名包的库,可以使用这些软件包版本:stdlib-package.jar和algs4-package.jar。



警告:如果正在使用普林斯顿COS 226或Coursera,算法,第一部分或第二部分,您必须使用我们的图书馆的默认软件包verison来促进分级。



显示我的测试成功:


I've started Coursera Algorythms course. Practice assignments must be done on Java and they suggest using DrJava as IDE, but its 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 classes from them 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 works.

Please, tell me, what I must 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:

这篇关于如何使用库的算法第一部分在Coursera课程在Eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆