CS 201: Data Structures (Spring 2017)
Lab1: Python to Java
During this lab, you will work with the following pairs of programs.
- conditionals.py and Conditionals.java -- conditionals
- person.py and Person.java -- toString and equality testing
- linereader.py and LineReader.java -- reading from file
- commandline.py and CommandLine.java -- processing command line arguments
- lists.py and Lists.java -- using lists
- split.py and Split.java -- split a string
- loops.py and Loops.java -- simple loops
There are lots of ways to explore sample programs like these, but here's a recommended procedure. For each pair of sample programs:
- Download the programs to your working directory by right-clicking on the link and choosing "Save Link As" or whatever similar option your browser gives you.
- Open the sample programs in a text editor.
- Try to have the Python and Java code side by side, so you can compare them.
- Read the programs with your partner. Discuss what you think the programs will do. Discuss differences between Python and Java implementations of the same tasks.
- Run the programs. See if your predictions about the programs were true. If not, try to figure out why not.
- Try to answer the questions in the programs' comments. You may want to test your answers by making changes to the program in your text editor, saving the changes, and running the program again. Play around with the program until you feel comfortable with all its operations. Ask questions.
- Move on to the next pair of programs.