0

This is it: I'm actually trying to improve my basic knowledge of Java implementing some exercises.

The point is that I want to have a REPL implemented with static methods in a class: it must display a prompt, instructions and then get a value from console, so the programmer should not care about parsing strings and so on. However, I don't want to implement this little REPL in every different exercise I do. I don't want to copy and paste code, neither.

Have I any option? I can program a lot in java, but I don't have a broad knowledge on libraries, files and directories in Java.

The ideal would be use that same class in every project-exercise, but I don't think that's possible, or may be too complex. However, maybe there must be an specific standar way to copy this class in every project, without being naïve by simply copying and pasting code.

Have I any option? Is there a way to create a little library for this purpose?

Josell
  • 1,924
  • 3
  • 13
  • 20
  • 1
    Of course, you can do that! Package your library as a JAR file, and reference it from your projects, instead of pointing to the source code. – Sergey Kalinichenko Dec 13 '13 at 14:13
  • I am not aware. What is REPL? – Aniket Thakur Dec 13 '13 at 14:14
  • Well, static methods are inherited just like any other. You could do something where a static method calls an abstract that your subclasses have to provide to do any custom code pieces with-in your REPL loop. – CodeChimp Dec 13 '13 at 14:16
  • 1
    @AniketThakur REPL == "Read Evaluate Print Loop" – CodeChimp Dec 13 '13 at 14:17
  • If you're using an IDE like eclipse you can also link any file system folder into your project and declare it as source folder. Then you're directly reusing the source but without copy-paste. Not as smart as a library, but sometimes easier to use. – isnot2bad Dec 13 '13 at 14:28

0 Answers0