除了line.separator属性,如果你使用的是Java 1.5或更高版本和的String.format(或其他格式化方法),可以使用
%n在
Calendar c = ...;String s = String.format("Duke's Birthday: %1$tm %1$te,%1$tY%n", c); //Note `%n` at end of line ^^String s2 = String.format("Use %%n as a platform independent newline.%n"); // %% becomes % ^^// and `%n` becomes newline ^^


