Java Collection and Iterator program

Recently just create a simple Java program which involves collection and iterator object and would like to share with you as follow.

package com.codingdirectional.www;

import java.util.ArrayList;
import java.util.Iterator;

public class CollectionDemo {

	public static void main(String[] args) {
		ArrayList<String> hello = new ArrayList<String>();
		hello.add("hello");
		hello.add("world");
		
		for (int i = 0; i < hello.size(); i++) {
		    String word = hello.get(i);
		    System.out.println(word);
		}
		
		hello.remove(0);
		
		for (int i = 0; i < hello.size(); i++) {
		    String word = hello.get(i);
		    System.out.println(word);
		}
		
		ArrayList<String> hi = new ArrayList<String>();
		hi.add("hello");
		hi.add("world");
		
		hi.removeAll(hello);
		
		for (int i = 0; i < hi.size(); i++) {
		    String word = hi.get(i);
		    System.out.println(word);
		}
		
		Iterator<String> hi_ = hi.iterator();
		while(hi_.hasNext())
			System.out.println(hi_.next());

	}

}

The outcome is as follows :

hello
world
world
hello
hello

How to create JavaFx project with Netbeans 8.1

Hi, this is the first article of my new article series on creating JavaFx game with Netbeans 8.1. In this article I am going to show you how to set up and launch the new JavaFx project in NetBeans 8.1. My new gaming project Mechanikal Reptile will use NetBeans to create and therefore if you have not yet installed NetBeans you can do so by visiting NetBeans homepage and download the IDE now. Also I am using Java 8 in this project so make sure you have the latest copy of the JDK installed in your computer.

Once you have installed NetBeans you can launch it and start a new project. Go to File->New Project, then select JavaFx and JavaFx Application on the right pane and click Next. Fill out the detail as follow, I have named my new game project Mechanikal Reptile and I have also created a main folder for all my Java project. Leave other settings as default and click on Finish.

NetBeans IDE
NetBeans IDE

OK, now we are ready to launch our first JavaFx project, select Run->Compile File to compile your Java code first then look at the output pane, if your code has no error then you will see the ‘BUILD SUCCESSFUL’ message which means we can now run the JavaFx program.

NetBeans Output
NetBeans Output

Now click on the green arrow button on the main menu header to run the project.

JavaFx
JavaFx

Nothing so special about this, as you can see NetBeans has already created a simple project for us to further modified it. We will go through all those codes in our next tutorial. By the way, this is what Mechanikal Reptile looks like on the website and my main objective is to create the desktop version!