Skip to main content

Posts

Showing posts with the label Java

What are the differences between Java & C++ Languages?

Everything is an object in Java( Single root hierarchy as everything gets derived from java.lang.Object). Java does not have all the complicated aspects of C++ ( For ex: Pointers, templates, unions, operator overloading, structures etc..). The Java language promoters initially said "No pointers!", but when many programmers questioned how you can work without pointers, the promoters began saying "Restricted pointers." You can make up your mind whether it's really a pointer or not. In any event, there's no pointer arithmetic.  There are no destructors in Java. (automatic garbage collection), Java does not support conditional compile (#ifdef/#ifndef type).  Thread support is built into java but not in C++. Java does not support default arguments.  There's no scope resolution operator :: in Java. Java uses the dot for everything, but can get away with it since you can define elements only within a class. Even the method definitions must always occur w...

What is JUnit & How To Use It?

JunitPithy is built using Apache Ant and Ant has JUnit support as an optional package. With junit.jar in the classpath, Ant should automatically detect it, but where you want to keep your default classpath clean, which is my preference when you are trying to have a code tree with minimal external dependencies, the quickest way to enable it is to copy the junit.jar file into the $ANT_HOME/lib directory. With junit.jar in place, the Ant task <junit> is enabled. With that in place, we can organise the test classes. Rather than mix the test code with the actual code, it is better to have a separate test hierarchy with its own class tree. Here's the opening of build.xml: <project name="PithyDerby" default="compile" basedir="."> <property name="sourceDir" value="src" /> <property name="outputDir" value="bin" /> <property name="testDir" value="tests" /> <propert...