Converting between binary and decimal representations of IEEE 754 floating-point numbers in C++, Java and Python
TweetThis post implements a previous post that explains how to convert 32-bit floating point numbers to binary numbers in the IEEE 754 format. What we have is some C++ / Java / Python routines that will allows us to convert … Continue reading
Polymorphism in Java
TweetAn example: import java.util.*; public class JavaPolymorph { public void Print() { System.out.println( “JavaPolymorph”); } public static void main(String[] args) { JavaPolymorph j1 = new JavaPolymorph(); JavaPolymorph j2 = new SubJavaPolymorph(); j1.Print(); j2.Print(); } } public class SubJavaPolymorph extends JavaPolymorph … Continue reading
Java Threads: The Basics
TweetMethod 1: Write a class that implements the Runnable interface (i) Put the thread code in the run() method. (ii) Create a thread object by passing a Runnable object as an argument to the Thread constructor. The Thread object now … Continue reading
Mathematical Expression Parsers in Java and C++
TweetBasic Expression Parsing Click here for advanced expression parsing When writing your own calculator it is necessary to build a converter that can transform an input mathematical expression such as ( 1 + 8 ) – ( ( 3 * … Continue reading
Reading Text Files into String Arrays in Java
TweetSome example Java code to read the contents of text file into a string array, line-by-line. Here is the Java class which is used to output the string array after the file location has been passed to it: // ReadFile.java … Continue reading
Java Collections: The Basics
TweetOne long section of code outlining how to use the Java Collections. As per the Java Strings post, this consists of one long code snippet outlining commonly used Java collections such as Hash Maps, Linked Lists etc. As this is … Continue reading
Java Strings: The Basics
TweetOne long section of code outlining how to achieve some basic string handling objectives in Java. Currently trying to get to grips with this language after spending far too many years concentrating on C++. Each technique is demonstrated with a … Continue reading
Getting Started with Java in NetBeans
Tweet1. Create a new project In the File menu, select New Project: And complete the remaining wizard step(s): 2. Write the code As with writing the “Hello World” example in the Eclipse IDE, fill in the bit of auto generated … Continue reading
Getting Started with Java in Eclipse
Tweet1. Open Eclipse and create a new project Select File -> New -> Java Project. Give your project a name and change the default locxation of the folder location, if desired. Click the Finish button: 2. Create a new Java … Continue reading