So over on Youtube someone asked me about doing exponents in Java. I didn’t talk about this in episode 3 of my Java tutorial, so I have created a short supplementary  video looking at some of the more advanced mathematical functions in Java. Short, and to the point. Here it is:

Join the conversation!

Hit me up on Twitter or send me an email.

This video looks at how we can use the OpenGL graphics library in our Java programs. This video was an entry in a competition on 3dbuzz.com. As such, it doesn’t flow on from the previous videos, just consider it a bonus.

[flashvideo filename=”video/02_02_opengl.mp4″ width=”480″ height=”360″ /]

Note that this video is 1024×768, so hit the full screen button to get more readable detail.


This video is the property of 3DBuzz Inc. Jason and Zak have kindly given me permission to host it on this website. Because it is not owned by me, I would appreciate it if you did not distribute this video. Cheers!

Join the conversation!

Hit me up on Twitter or send me an email.
Posted on December 11, 2008Java Video TutorialsTags: 3dbuzz, java, jogl, opengl, Programming, tutorial, video

This video gives an overview of the Eclipse IDE. Eclipse is a feature packed Java development environment that is also free and open source. In this video we see how we create projects in eclipse and run our programs.


You can get Eclipse from http://www.eclipse.org. It is available for pretty much all platforms. If you’re on Linux it is probably in your distribution’s repository.

Join the conversation!

Hit me up on Twitter or send me an email.

Our first look at a data structure – arrays. First we talk about what arrays are, then explain how we can use them with loops to do something useful. We also have a look at the String[] argument to the main method.

Join the conversation!

Hit me up on Twitter or send me an email.

Well, the Java VTM series 1 has been incredibly well recieved. Thankyou everyone for your support and comments about my videos. However, I’ve got a couple of things to fix regarding the videos, so here are some series 1 corrections.

So whats wrong with the videos? Nothing actually, but times change. Java has evolved over the years and the API gets bigger with every release. See, when I started learning Java, version 1.4 had just been released. In this version, like the version before that there was no simple way to extract data from the keyboard. Enter the Keyboard class. This is a java file that I wrote for the Java VTM. It has simple methods for getting data from the keyboard, so that you don’t have to do it yourself.

However, times change. With the release of Java 5 extracting data from the keyboard has never been easier. What this means for you is that you can pretty much throw my Keyboard class away. It is now obsolete. There is now a standard Java class called Scanner. Have a look in the Java API. There are all these methods like nextInt, nextDouble, nextLine etc. What Scanner does is provide a simple way to get data from the keyboard (any InputStream actually), so we don’t have to do the hard work ourselves.

Lets look at at the following code from Video 4 in the VTM. This is how the video explained how to get data from the keyboard.

int testInt;
double testDouble;
char testChar;
testInt = Keyboard.readInt();
testDouble = Keyboard.readDouble();
testChar =  Keyboard.readChar();

Now lets change the code so we use Scanner instead. The first thing we need to do is create an instance of Scanner. There are a couple of constructors available, but the one we are interested in takes an InputStream as its parameter. If we want to get data from the keyboard, we need to pass in System.in as the parameter.

Scanner keyboard = new Scanner(System.in); //create a scanner object

Now that we have the scanner ready to go, we can use all of its methods to access data that I did using my Keyboard class. The code below shows how we can get numbers from the keyboard.

testInt = keyboard.nextInt();
testDouble = keyboard.nextDouble();

So what about characters? Well, there isn’t a dedicated method for getting a character from Scanner. Same with Strings. There is a method called nextLine() in Scanner, but it doesn’t really do what you expect. If there is a line waiting to be read on the InputStream (such as in files), it will read the line. However, if there isn’t a line waiting to be read you will get an exception! Not fun. So, for doing character and String reading a BufferedReader is the way to go.

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

With BufferedReader you can read in lines or characters from an input stream. So to get a character and string you would do the following:

System.out.println("Please enter a char");
//readline returns a String, so we get the character
testChar = reader.readLine().charAt(0);

System.out.println("Please enter a String");
testString = reader.readLine();

Note that the code above should be contained within a try block, as an IOException may be thrown.

So with that, throw away Keyboard.java because you don’t need it all. The ever expanding Java API now has all of Keyboard’s functionality and a whole heap more. Finally there is an easy way to get data from the keyboard, without having to write your own classes. Here is the full Java file from VTM 4, using Scanner and BufferedReader instead of the Keyboard class.


Join the conversation!

Hit me up on Twitter or send me an email.