Long myLong = 123456789L; String myString = myLong.toString(); System.out.println("Long to String: " + myString);
String myString = "987654321"; Long myLong = Long.parseLong(myString); System.out.println("String to Long: " + myLong);Output: String to Long: 987654321 Both of these examples use the java.util package library, specifically the Long class, to convert Long values to Strings and vice versa. The toString() method is used to convert Long to String while Long.parseLong() is used to parse a String to a Long value.