I found a suggestion on this forum that including the caption package should do it, but it didn't help me in a listing environment
Code: Select all
Code, edit and compile here:
\documentclass{book}\usepackage{listings}\usepackage{caption}\begin{document}\lstinputlisting[float, caption={testcaption\\ multiline}, label={testlabel}]{sample.java}\end{document}
Since Java files are not allowed to be attachted, I included the code in a code environment
Code: Select all
class Sample{private Object fVariable = new Object();public static void main(String[] args){int w = 0;boolean bool = true;for(int i = 0; i<w; i++){if(bool){System.out.println("Testing of the listing package");} else{/* Some blockcomments* More comments* And the last line of comments*/System.out.println("This code makes absolutely no sense");}}}public Object getVariable(){//Some testcommentreturn fVariable;}}