Program to replace the spaces of a string with a specific character

Source Code:

public class ReplaceSpaces {
public static void main(String[] args) {
String s = “java is easy”;
String res = s.replace(‘ ‘, ‘-‘);
System.out.println(res);
}
}

Output: