Your Computer Science Resource

Posts Tagged ‘Java’

Jun
1st

HOW-TO: Retrieve a File’s extension in Java

For some strange reason, there’s no getFileExtension() or getExtension() method in Java’s File class (perhaps because Files do not necessarily always have extensions in every platform?). Nevertheless, that doesn’t mean we can’t do it on our own. All it takes is one line of code!

(more…)

May
7th

HOW-TO: Use the Levenshtein Distance Algorithm

For an anti-plagiarism application I developed about a year ago, I needed a way to calculate the similarity between two strings. I wasn’t sure how to go about doing this at first, but then I came across the Levenshtein Distance Algorithm which gets the job done well. In this example, I’ll show you my Distance class implementing the Levenshtein Distance Algorithm, and how to use it to compare strings (specifically the minimum distance between two strings needed to make them equal). This is also very useful for determining how similar (or dissimilar) two strings are.

(more…)

Mar
20th

PROJECT: Binary Search Tree

If you’re a CS student, it’s only a matter of time before you have to write a program implementing a Binary Search Tree. Below, I will go through how I would do it, but what makes this version different from most other examples on the Internet is that this one loads a configuration file (list of commands) and gives a specific output according to the instructions for my class at the time. Because the code to this assignment is pretty lengthy, I’ve made the source code available for download (MyBinarySearchTree.zip).

(more…)

Mar
19th

HOW-TO: Set Up Your Java Environment

So you’re ready to start learning Java, but you don’t know where to begin. The first thing you need to do is download, install, and set up your Java environment. Because there are different development kits for Java, it can sometimes be confusing for a new user to understand which one they need to download.

(more…)