Java is very closesly related to C++, it was designed that way. Functions work pretty much the same way that they do in C++, but the thing is that everything has to be in a class. So to start you calculator example you might start with something like:
Code:
public class Calculator {
public int clac(String expr) {
// ... Code for evaluating goes here
}
public static void main(String[] argv) {
System.out.println(new Calculator().calc(argv[0]));
}
}
If you want to learn Java, I would look at some of the tutorials online. Sun has some decent ones: http://java.sun.com/docs/books/tutorial/.
I hope this helps.
Bookmarks