java

Resource Management in Game

Introduction This post is the next in the game development series. In this post we will learn about Resource Management in the Game. After writing the game engine, now we can add some background to our game. We will try to add our menu as well and try to add navigation in the menu. Once that is done we will be able to move through the menu and choose various options. Without wasting much time, lets dive in. Objects in the Game There are many different type of entities in our game. They can be categorized into Screens and Actors and few more. You have absolute freedom to make it more gran...
Read More

Understanding Classes in Java

Introduction After gathering some insight into Java Reference Types in the previous posts, now understanding classes in Java has become easier. We need to understand how a Reference Type comes to existence and more. Apart from that we must also learn about Interfaces and Enums which are the building blocks of any written program. A Class in Java A class declaration defines a new reference type and describes its implementation. A class contains members which are enclosed in the body of the class. Members may also be inherited from a Super Class or Interfaces. A member can be a field, a...
Read More

A Generic toString in Java

Alternative to Java's toString() method: A generic toString in java For the impatient readers who know the problem I am trying to solve and need the code can scroll down to the Source code section. If you are still reading then, let us describe the problem in hand. Problem Statement Have you ever faced an issue where you included a POJO(Plain Old Java Object) in your source code and tried to print it's state in the logs or may be on the console. But unlike your expectations you ended up with some ugly object references which gives no good representation of the data you require. This t...
Read More

Using Abstract Classes And Interfaces

Introduction This article is going to be a short one with some details about the interfaces and abstract classes in java. There have been a lot of confusion about using them interchangeably, but as I always say, encapsulation is a strong feature of java and one of the most important rule in java is that every thing has its own purpose. Hence, if two distinct features (abstract class and interface) exists in the language, then they must have different reasons as well. Purpose of the Article The article describes in detail using Abstract Classes And Interfaces, what is the difference between ...
Read More

Interview Question – Static variables

Introduction This question was asked in a recent java interview in Goldman Sachs, this isn't complicated but candidates might get confused solving it. This is about static blocks and static variables initialization, so I publish this article under the heading Interview Question - Static variables. To get updates on the other articles in the series, please use the Subscribe feature on the right panel. Problem Statement What would be the result when the below code is executed? [crayon-587ddb76adfc7774036885/]   Solution What is the approach for solving this question? Remember your b...
Read More

Comparable and Comparator – a detailed discussion

Introduction This article is in response to a question asked on one of the groups I am a member of. What is the difference between Comparable and Comparator interfaces in Java. Why there are two interfaces if what they do is provide a method to compare. This might not seem to be a topic worth discussion for people who are experts in java, but yeah for many of my friends out there, it might help. Purpose of the article The article will describe in detail the difference between the interfaces Comparable and Comparator and also define the usages of both of them. One thing we need to underst...
Read More

Java-Spring Web Application – Maven

Here we learn to create a simple web application in Java and Spring using Maven build and dependency management tool. There are several articles written with various alternatives. Java-Spring Web Application - Maven, is the simplest article and it helps in creating the simplest web application. It just demonstrates integrating Spring MVC using maven. It also demonstrates the capabilities of maven, how we can get rid of the traditional approach of including each jar in the class path by manually searching and downloading it. First for the impatient programmers: Complete the following prere...
Read More