I covered a few things about Java and recommend two sources about Java for C++ programmers:
- Java programming for C/C++ developers You need to register to read this. It's a little old, but still useful.
- Java for C++ Programmers I haven't read the whole thing, but the Table of Contents addresses a lot of the topics I would cover if I were writing such an article.
I mentioned that my most common error coming to Java from C++ is in declaring variables:
TrafficLight tLight;In both languages, this declares a variable named tLight. In C++, the variable is of type TrafficLight and the instance is initialized by a constructor. In Java, the variable is of type reference to TrafficLight and is initialized to null. To create an actual object, use
TrafficLight tLight = new TraffcLight();Some other points I made:
- One public class is defined in a file. The class
Foomust be defined in file foo.java. - Classes are organized into packages. All the classes in a package must be in a directory that has the name of the package.
- A Java source file is compiled using javac, the Java compiler. The output of the compiler is a class file—e.g., Foo.class.
- A Java program is run using the Java Virtual Machine (JVM) via the java command. The class method having the signature
public static void main(String args[]);is invoked as the starting point of a program. - A Java program is usually a collection of packages and classes that are stored together in a Java archive (.jar) file. [In fact, Netbeans stores the classes for each project in a separate .jar file.]
We went to the lab and I tried, anyway, to introduce you to regular expressions. We had trouble using the NetBeans edtor, but it worked in vim. Regular-Expressions.info seems chock full of info about regular expressions.

No comments:
Post a Comment