Languages
[Edit]
EN

Java - calculate Levenshtein distance between strings

7 points
Created by:
Maggotta
499

In this short article, we would like to show simple Java implementation for the Levenstein distance algorithm.

Levenstein distance algorithm is used to measure the difference between two sequences (e.g. between two strings).

When the algorithm returns 0 it means: compared objects are equal.

Simple implementation:

Output:

 

Levenstein distance algorithm with case-insensitive

Edit

It is necessary to wrap the existing algorithm with toLowerCase() or toUpperCase() string transformation.

Output:

See also

Edit
  1. Java - Math.min() with multiple arguments

References

Edit
  1. Levenshtein distance - Wikipedia
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Java - string metrics algorithms

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join