Python to Java: Class Discussion -- Tuesday, January 26, 2010 at 12:30 - Room 101, WWH


Class Discussion:

Concepts
Sample Python 2.6 program
Sample Java program
IDE and introduction Discussion on Python:
using IDLE
Using indentation for blocks of code
Statement terminator: not needed!
Operators: for concatenation/repeition
Discussion on ** for exponentiation.
Data types review: int, float, string, boolean
Discussion on Java:
using JCreator
Using braces for blocks of code
Statement terminator: semi-colon
Operators: + for concatenation
There is no ** operator for exponentiation.
Data types: int, float, double, char, boolean
Hello, World! Hello, world! "hello, world!" in Java
Working with integers integer arithmetic integer arithmetic
Data entry: text data entry data entry: text
Data entry: numbers data entry data entry: numbers
Selection statements: if/else Rolling a virtual die Rolling a virtual die
Selection statements: switch (not available) Rolling a virtual die
Repeetition: while loops Basic while loop Basic while loop
Repetition: for loops Nested for loop Nested for loop
Working with Strings Basic loop for working with a string Basic for loop for working with a String
Repetition: do/while loops (not available) do/while loop: looking for snake eyes!
Writing a method / function Green Eggs and Ham - using a function Green Eggs and Ham - using a void function
Writing a method / function which returns a value Converting temperatures -Fahrenheit & Celsius Converting temperatures -Fahrenheit & Celsius
Using an array / list to roll a virtual die Rolling a virtual die - using an array for totals Rolling a virtual die - using an array for totals

For further reference, see From Python to Java by Ken Lambert
Professor in the Department of Computer Science, Washington and Lee University

For class discussion ... on the structure of a Java method (adapted from Daniel Liang's textbook, Introduction to Java Programming):