System.out.println(“Inamnanboy”);
System.out.println(“I am a boy”.replaceAll(“\s+”,”n”));
System.out.println(“I am a boy”.replaceAll(“\s+”,System.getProperty(“line.separator”))); // portable way
You can also use System.lineSeparator():
String x = “Hello,” + System.lineSeparator() + “there”;