Skip to content

Instantly share code, notes, and snippets.

@mweppler
mweppler / Singleton.class
Created August 3, 2011 17:19
Wiki Definition: "In software engineering, the singleton pattern is a design pattern used to implement the mathematical concept of a singleton, by restricting the instantiation of a class to one object."
// Traditional Simple Way:
public class Singleton {
private static final Singleton instance = new Singleton();
private Singleton() {
}
public static Singleton getInstance() {
return instance;
}
}
@mweppler
mweppler / TriangleNumbersPuzzle.java
Created May 18, 2011 02:52
Coding: Triangle Numbers Puzzle - from http://www.gild.com/
package pack;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class TriangleNumbersPuzzle
{
private static int returnNumberOfDivisors(int inNum)