Connected Components Using JAVA