To convert
long
to String
in Java, use String.valueOf
.long longNumber = 2L;
String numberAsString = String.valueOf(longNumber);
if (numberAsString.equals("2")) {
System.out.println("Converted!");
}