Java multiline string

前端 未结 30 2901
醉梦人生
醉梦人生 2020-11-22 15:55

Coming from Perl, I sure am missing the \"here-document\" means of creating a multi-line string in source code:

$string = <<\"EOF\"  # create a three-l         


        
30条回答
  •  一生所求
    2020-11-22 16:34

        import org.apache.commons.lang3.StringUtils;
    
        String multiline = StringUtils.join(new String[] {
            "It was the best of times, it was the worst of times ", 
            "it was the age of wisdom, it was the age of foolishness",
            "it was the epoch of belief, it was the epoch of incredulity",
            "it was the season of Light, it was the season of Darkness",
            "it was the spring of hope, it was the winter of despair",
            "we had everything before us, we had nothing before us",
            }, "\n");
    

提交回复
热议问题